|orm.xml vs Annotations [message #379030]
||Fri, 08 August 2008 11:21
| Jason Drake
Registered: July 2009
I am in the process or doing some refactoring of one of my services |
libraries (representing the object model of a stamp collection). In the
past I had annotated the classes with JPA annotations, and this time I
have chosen to go with orm.xml for my persistence descriptors.
What is the communities opinion on the use of orm.xml vs. annotations?
One downside I saw (I had some unit tests fail) was that since my entity's
didn't have a @Entity annotation, my utility method to extract the
identity of an object (if it was a JPA entity) failed since the case of
".isAnnotationPresent(Entity.class)" no longer existed.
Of coures the benefit of an orm.xml is I can reference eclipselink classes
without having a compile tme dependency on eclipselink (ie. just the
javax_persistence_1.0.0.jar). It is also "one stop shopping" to see the
relationships. While most of the annotations are javax.persistence but
some functionality might be provider specific (I know when I used to use
Hibernate I had some old ForeignKey annotations). Another benefit of
orm.xml (as I see it) is I can add query hints directly to the
NamedQueries rather than doing it programmatically by provider at runtime.
Again the lack of compile dependency.
Finally, I have to admit getting orm.xml working without Dali would be a
royal pain. Whereas using annotations was easy (I have it is non-dali
enabled project today). One Dali comment is that it doesn't seem to work
well with one or the other. ie. when you view the java class it wants to
add annotations, when you are in orm.xml it deals with XML. It'd be nice
if you state that bean X is to be managed by orm.xml to be able to manage
the JPA properties from the java class injecting the info into orm.xml.
Looking forward to reading everyone's opinions.
Powered by FUDForum
. Page generated in 0.02102 seconds