2 Replies Latest reply on May 5, 2008 11:00 AM by Viktor Rees

    Default Persistence Unit

    Viktor Rees Newbie

      We are using more than one Persistence Unit e.g.



         <persistence-unit name="AdaptTemplates">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <jta-data-source>java:/AdaptTemplatesDatasource</jta-data-source>
            <properties>
               <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9Dialect"/>
               <property name="hibernate.show_sql" value="true"/>
               <property name="hibernate.format_sql" value="true"/>
               <property name="jboss.entity.manager.factory.jndi.name" value="java:/AdaptTemplatesEntityManagerFactory"/>
               <property name="hibernate.default_schema" value="J2EETST11"/>
            </properties>
         </persistence-unit>
      
         <persistence-unit name="AdaptTemplates2">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <jta-data-source>java:/AdaptTemplatesDatasource</jta-data-source>
            <properties>
               <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9Dialect"/>
               <property name="hibernate.show_sql" value="true"/>
               <property name="hibernate.format_sql" value="true"/>
               <property name="jboss.entity.manager.factory.jndi.name" value="java:/AdaptTemplatesEntityManagerFactory2"/>
               <property name="hibernate.default_schema" value="J2EETST13"/>
            </properties>
         </persistence-unit>



      Is there a way do config a default persistence unit, which is used when no unitName is entered in @PersistenceContext?


      @PersistenceContext
      private EntityManager em1;
      
      @PersistenceContext(unitName="AdaptTemplates2")
      private EntityManager em2;