openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "francisco treacy" <francisco.tre...@gmail.com>
Subject problem enhancing embeddable class
Date Sun, 16 Dec 2007 16:00:51 GMT
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

Mime
View raw message