Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » add list of entities(adding list of entites to module)
add list of entities [message #1182843] Tue, 12 November 2013 12:58 Go to next message
f bratic is currently offline f braticFriend
Messages: 2
Registered: November 2013
Junior Member
Hi everybody

i was searching the forum now for hours, but couldn' really find an answer.

Image I have two java (maven) projects.
ProjectA
ProjectB

ProjectB is included in ProjectA as dependency.

In ProjectA I created some entities with all the necessary Annotations
e.g. my classes are
Building
Address
Organization
etc

now in ProjectB I have the creation of entityManager with
em = Persistence.createEntityManagerFactory(persistenceUnit, properties)

and now:
i would like to add to this new em a list of classes.

How?

How can I programmatically (ergo not through persistence.xml) give the EntityManager a list of classes (entities) that he should use.

thank you very much for your help

ps.:
if I am not clear ... please tell me ...
and I will try to explain it in a different way ...
Re: add list of entities [message #1183000 is a reply to message #1182843] Tue, 12 November 2013 15:20 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
JPA seems designed that each independent set of classes would use their own persistence unit, so they aren't meant to be dynamically added to a persistence unit defined elsewhere. Classes are defined statically for the most part unless you are using dynamic entities, so if you add say a jar to the classpath and want to use entities defined within it, your application would look up the associated persistence unit defined within the jar.

That said, it is possible with EclipseLink to change the mappings and add entities dynamically, or even use dynamic entities. See http://wiki.eclipse.org/EclipseLink/Examples/JPA/Dynamic for some dynamic entity examples, while http://wiki.eclipse.org/EclipseLink/DesignDocs/340192#EntityManagerFactory_and_Metadata_Repository has the intial design doc for the metadata repository which can be used to bring in additional ORM classes and mappings to the persistence unit. The XMLMetadataSource is an implementation of the MetadataSource interface that reads in an orm.xml file, but you can write your own implementation as necessary.
Re: add list of entities [message #1183061 is a reply to message #1183000] Tue, 12 November 2013 16:02 Go to previous message
f bratic is currently offline f braticFriend
Messages: 2
Registered: November 2013
Junior Member
hi ...

first .. thank your for your answer.

I already read about the concept of Dynamic entities, but I didn't found a good and easy way to create Dynamic entities out of existing ones.


Any suggestions how to do that? (without creating/writing an own orm.xml file etc etc)
Previous Topic:Updating Child Table when updating parent entity
Next Topic:[MOXy] NoClassDefFoundError within OSGi
Goto Forum:
  


Current Time: Fri Apr 26 06:46:06 GMT 2024

Powered by FUDForum. Page generated in 0.02562 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top