3 Replies Latest reply on Nov 5, 2010 2:06 AM by jaikiran

    duplicate persistence unit in same EAR

    asookazian

      I have an EAR with multiple JARs.  There are two persistence.xml files that have the same persistence unit name.  These PUs are showing up twice in the persistence units section of jmx-console (jboss 4.2.x).

       

      • ear=com.echo.reports.ear-1.5.2-SNAPSHOT.ear,jar=com.echo.billing.reports.dao.gemini-1.5.2-SNAPSHOT.jar,unitName=reports-persistence-unit
      • ear=com.echo.reports.ear-1.5.2-SNAPSHOT.ear,jar=com.echo.billing.reports.services.persistence-1.5.2-SNAPSHOT.jar,unitName=reports-persistence-unit

       

      What negative effect, if any, will this have on my app?  For example, during deployment the Seam container rejects Seam components with the same name.  I'm not sure if JBoss is doing that or not.  thx.

        • 1. Re: duplicate persistence unit in same EAR
          wdfink

          I use ATM JBoss 4.3 to migrate to EJB.

          I have also some found some problems with persistence units,

          - difficult autoimatic detection of entity classes

          - problems with the naming (like you have) and that the units must be unique named

          Also the bhaviour has changed in JBoss 5x

           

          So in fact I'm also a bit unsteady about this.

          • 2. Re: duplicate persistence unit in same EAR
            asookazian

            I'm assuming it's ok as per JSR220 (or JPA 1.0 spec), etc. to allow multiple persistence units with the same name in the same EAR.  Otherwise, this is erroneous behavior from JBoss.

             

            What I'd like to know is how JBoss handles this scenario (i.e. are just one or both of the PUs actually used, etc.)?

            • 3. Re: duplicate persistence unit in same EAR
              jaikiran

              Arbi Sookazian wrote:

               

              I'm assuming it's ok as per JSR220 (or JPA 1.0 spec), etc. to allow multiple persistence units with the same name in the same EAR.  Otherwise, this is erroneous behavior from JBoss.

               

              Multiple persistence units with same name are allowed. But which one gets used depends on "where" it's being used. The JPA2 (or even JPA1 spec) has a section named "Persistence Unit Scope" which has the complete details.