Multiple persistance unit simultaneously, issue.
I have a doubt, regarding multiple persistence units. The unitName element specifies the name of the persistence unit, in the persistence.xml file. A persistence
unit is essentially a grouping of entities used in an application. It is ok. Let say I want to have multiple persistence units, so when I create EntityManager, specifying the unit I want, it will manage that classes.
So I should have persistence.xml file, like this :
So, when I get an EntityManager of persistence unit named GeneralUnit , it will be used for managing clases under that persistence unit, right?
1. <persistence-unit name="PartucularUnit" transaction-type="JTA">
10. <persistence-unit name="GeneralUnit" transaction-type="JTA">
If all this presumptions are ok, my question is :
"If I use property :
inside persistence-unit element, configuration, it means it will detect all @Entity classes. Do I need for each persistance context, to list a classes I want that particular EntityManager. to handle"?
<property name="hibernate.archive.autodetection" value="class, hbm"/>
Or should I just create separate Ejb-jar for each persistence context, group of "stand alone" classes?
I mean, that my each .jar file, to contains its own classes, and one persistence.xml configuration file, with only one persistence-unit declared, related to the classes in that .jar?