Sahoo (no last name provided, all apologies!) has written a blog called "An annotation processor to update your persistence.xml during javac" to automatically generate a persistence.xml file for entity persistence. While aimed at EJB3 users from J2SE, the facility might be useful for J2EE users, to keep updated as well.
From the introduction:
When Java Persistence API is used in a managed environment (like Java EE container), there is often a deployment step and a notion of deployable module (an ear/war/jar) that represents the boundary of an application. During deployment container/persistence provider can discover managed persistence classes by introspecting .class files bundled in the application. But when Java Persistence API is used in Java SE environment, there is no such predefined deployment step, nor is there any deployable module. So a persistence provider does not know what are all the classes to introspect. Hence the spec requires users to specify the list of managed persistence classes in persistence.xml. A managed persistence class is a class that is either an Entity or Embeddable or EmbeddableSuperclass.
In this article, I shall show how to write an Annotation Processor that can be used along with J2SE's Annotation Processing Tool to automatically generate the list of managed persistence classes and update persistence.xml during compilation of entity source code.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment