Add entities programmatically [message #1233653] |
Mon, 20 January 2014 02:50  |
Eclipse User |
|
|
|
Hey all,
with hibernate i can add entities programmatically this way:
sessionFactory = new AnnotationConfiguration()
.addPackage("test.animals")
.addAnnotatedClass(Flight.class)
.addAnnotatedClass(Sky.class)
Is there something similar in EclipseLink?
This question is often asked but i could not find a satisfing answer. One answer said Dynamic JPA could be a solution but the description says:
"map relational tables to virtual classes which are created dynamically at runtime"
My classes are not created dynamically, they are already existing, but have to be registered at the entityManager.
Thanks for any help in advance,
Thomas
|
|
|
|
|
|
Re: Add entities programmatically [message #1235150 is a reply to message #1234976] |
Thu, 23 January 2014 12:14  |
Eclipse User |
|
|
|
Yes, you can dynamically change the persistence unit using a metadata source to add in what is needed: http://wiki.eclipse.org/EclipseLink/Examples/JPA/MetadataSource
With this, you can define your own Metadata source that can return your classes from outside the persistence unit. The metadata source is akin to an orm.xml file and is processed about the same time, so you would only need to list the classes and they will then get processed regularly.
This feature ships with an implementation that will load orm.xml files, but I have seen others post more dynamic implementations I just don't have any links or examples handy.
|
|
|
Powered by
FUDForum. Page generated in 0.04284 seconds