openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick Linskey" <plins...@gmail.com>
Subject Re: problem enhancing embeddable class
Date Sun, 16 Dec 2007 18:22:46 GMT
> 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)
> (...)

Do you do anything interesting in your getters or setters for the
embedded field?

> 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)

Is that the full stack? What is output if you set the openjpa.Log
property to 'Enhance=TRACE, Tool=TRACE'?

Also, FYI, what you're doing sounds legal, and we do have test cases
that exercise embedded fields, so there must be something odd going
on. Do you have some sample code that you could post?

-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