Results 1 to 2 of 2
  1. #1
    afrodom is offline Member
    Join Date
    Feb 2010
    Rep Power

    Default 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 :
    Java Code:
       0.  <persistence>
       1. <persistence-unit name="PartucularUnit" transaction-type="JTA">  
       2. .  
       3. .  
       4. .  
       5. .  
       6. .  
       7. </persistence-unit>  
      10. <persistence-unit name="GeneralUnit" transaction-type="JTA">  
      11. .  
      12. .  
      13. .  
      14. .  
      15. .  
      16. </persistence-unit>  
      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 :

    Java 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?
    Last edited by afrodom; 03-06-2010 at 04:09 PM. Reason: addition of question

  2. #2
    afrodom is offline Member
    Join Date
    Feb 2010
    Rep Power


    Hi. Problem resolved. Cleaner is with multiple ejb-jars :)

Similar Threads

  1. Why my threads don't run simultaneously?
    By Gilvan Justino in forum New To Java
    Replies: 7
    Last Post: 01-16-2010, 02:43 AM
  2. Intellij-Hibernate persistance model warnings
    By eborix13 in forum IntelliJ IDEA
    Replies: 0
    Last Post: 04-20-2009, 09:58 PM
  3. Replies: 1
    Last Post: 12-21-2008, 10:06 AM
  4. p-unit 0.12
    By Jamie in forum Java Software
    Replies: 0
    Last Post: 06-16-2007, 10:33 AM
  5. p-unit 0.11
    By levent in forum Java Software
    Replies: 0
    Last Post: 06-04-2007, 09:07 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts