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.
| Online: | 25 Members of 4495 |
| Forum: Seam Users |
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;
I have never tried this, but the unitName of @PersistenceContext defaults to "" so you could name your default persistence-unit "" and that should work.
@Chris I tried your idea to set name="" in persistence.xml for the default persistence-unit. Unfortunately I got following error:
So, I will forget the idea of an default persistence-unit for the moment.
Thanks
Viktor