Multiple persistance unit simultaneously, issue.
Hi everyone.
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 :
Code:
0. <persistence>
1. <persistence-unit name="PartucularUnit" transaction-type="JTA">
2. .
3. .
4. .
5. .
6. .
7. </persistence-unit>
8.
9.
10. <persistence-unit name="GeneralUnit" transaction-type="JTA">
11. .
12. .
13. .
14. .
15. .
16. </persistence-unit>
17.
18. </persistence>
So, when I get an EntityManager of persistence unit named GeneralUnit , it will be used for managing clases under that persistence unit, right?
If all this presumptions are ok, my question is :
"If I use property :
Code:
<property name="hibernate.archive.autodetection" value="class, hbm"/>
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"?
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?