openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "francisco treacy" <francisco.tre...@gmail.com>
Subject Re: problem enhancing embeddable class
Date Sun, 16 Dec 2007 23:15:56 GMT
thanks patrick, it works now!

i did the following:
-replaced openjpa-1.0.1.jar by openjpa-1.1.0-SNAPSHOT.jar
-tried using runtime enhancement (meaning i didn't use the ant
build-time enhancement)
-included test.domain.Address in list class in persistence.xml

however, i couldn't figure out how to use the openjpa.MetaDataFactory
property in order not to list classes in persistence.xml. mine is:

<property name="openjpa.MetaDataFactory"
value="jpa(ClasspathScan=test/domain)" />

i tried many combinations but can't make it work (Known entity names: []).
for a layout like the following, what should i put?

   |-src
   |---test
   |-----domain
   |-------Address.java
   |-------Doctor.java
   |-web
   |---WEB-INF
   |-----lib
   |-----classes
   |-------test
   |---------domain
   |-----------Address.class
   |-----------Doctor.class
   |-test
   | (...)

thanks again,

francisco


On Dec 16, 2007 7:40 PM, Patrick Linskey <plinskey@gmail.com> wrote:
> > if i do, i get a
> > java.lang.NullPointerException
> >      at org.apache.openjpa.enhance.PCEnhancer.fromBackingFieldName(PCEnhancer.java:3680)
> >      at org.apache.openjpa.enhance.PCEnhancer.replaceAndValidateFieldAccess(PCEnhancer.java:858)
> >      at org.apache.openjpa.enhance.PCEnhancer.replaceAndValidateFieldAccess(PCEnhancer.java:807)
> > (...)
>
> FYI, it looks like that NPE has been resolved in OpenJPA 1.1.0.
>
> -Patrick
>
> On Dec 17, 2007 12:00 AM, francisco treacy <francisco.treacy@gmail.com> wrote:
>
> > hi,
> >
> > i migrated my application from hibernate jpa to openjpa a couple of
> > weeks ago, and except for an issue with sublists the integration was
> > seamless.
> >
> > i later changed my DI framework (spring to guice) and in some of those
> > changes i started having "Could not locate metadata for the class
> > using alias... " errors. it was then that i found out i had to list
> > all my entities in persistence.xml.
> > i don't get why it didn't happen before, or with hibernate. i know
> > it's in the spec, but anyway my question is:  is there a way to avoid
> > listing every class in persistence.xml? or, instead, a way to indicate
> > the package? i feel it's kind of like going against "don't repeat
> > yourself", considering all these classes are already annotated.
> >
> > but my real problem comes when i want to create (ddd) value objects.
> > these don't have identity and as such, should be "embedded" to
> > entities. i followed this post
> > http://debasishg.blogspot.com/2007/09/domain-modeling-with-jpa-gotchas-part-2.html.
> >
> > for instance, my Doctor entity has an Address. i'm using the
> > @Embeddable annotation in the Address class and @Entity in Doctor,
> > which has an @Embedded Address attribute.
> >
> > if i don't put <class>test.domain.Address</class> in the
> > persistence.xml file, i get a
> > <openjpa-1.0.1-r420667:592145 nonfatal user error>
> > org.apache.openjpa.persistence.ArgumentException: One or more of the
> > types in [(here lots classes...)] have relations to other unenhanced
> > types that were not specified. These unspecified types are: [class
> > test.domain.Address]
> >
> > if i do, i get a
> > java.lang.NullPointerException
> >      at org.apache.openjpa.enhance.PCEnhancer.fromBackingFieldName(PCEnhancer.java:3680)
> >      at org.apache.openjpa.enhance.PCEnhancer.replaceAndValidateFieldAccess(PCEnhancer.java:858)
> >      at org.apache.openjpa.enhance.PCEnhancer.replaceAndValidateFieldAccess(PCEnhancer.java:807)
> > (...)
> >
> > it should work like that, since enhancement is optional. but i decided
> > trying to enhance all entities by executing the ant task (and not
> > listing Address in persistence.xml), i get a
> > <openjpa-1.0.1-r420667:592145 fatal user error>
> > org.apache.openjpa.persistence.ArgumentException: The type "class
> > test.domain.Address" has not been enhanced.
> >
> > if i do list it, while executing the ant task i get a
> >      [java] Exception in thread "main" <openjpa-1.0.1-r420667:592145
> > nonfatal general error> org.apache.openjpa.util.GeneralException: An
> > error occurred while enhancing test.domain.Address. Exception message:
> > null
> >      [java]     at org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:470)
> >      [java]     at org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4349)
> >
> >
> > any ideas? what am i doing wrong?
> >
> > thanks in advance!
> >
> > francisco
> >
>
>
>
>
> --
> Patrick Linskey
> 202 669 5907
>

Mime
View raw message