Help

Controls

PermLinkWikiLink

Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

Forum: Seam Users Forum ListTopic List
30. Apr 2008, 11:54 CET | Link

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;

2 Replies:
30. Apr 2008, 17:18 CET | Link

I have never tried this, but the unitName of @PersistenceContext defaults to "" so you could name your default persistence-unit "" and that should work.

05. May 2008, 11:00 CET | Link

@Chris I tried your idea to set name="" in persistence.xml for the default persistence-unit. Unfortunately I got following error:

Empty string is not allowed for a persistence unit. Fix your persistence.xml file

So, I will forget the idea of an default persistence-unit for the moment.

Thanks

Viktor