- The application is running on JBoss 5.1
- Seam is used to manage the lifecycle of EntityManager instances
Here's the configuration:
- Datasource configuration file placed in {server}/deploy
JNDI name is Datasource - Persistence unit configuration in persistence.xml
<persistence-unit name="PersistenceUnit" transaction-type="JTA"> >
<providerorg.hibernate.ejb.HibernatePersistence </provider >
<jta-data-source >Datasource </jta-data-source >...... >
<properties <........
>property name="jboss.entity.manager.factory.jndi.name" value="java:/EntityManagerFactory"/ < >/properties
- Declaration of persistence-unit-ref element in web.xml
<persistence-unit-ref>
<persistence-unit-ref-name>PersistenceUnit/pu</persistence-unit-ref-name>
<persistence-unit-name>PersistenceUnit</persistence-unit-name>
</persistence-unit-ref> - Configuration in component.properties
seamBootstrapsPu=false
seamEmfRef=#{null}
puJndiName=java:comp/env/PersistenceUnit/pu - Configuration of persistence managed context in components.xml
<persistence:managed-persistence-context name="entityManager" auto-create="true"
entity-manager-factory="@seamEmfRef@"
persistence-unit-jndi-name="@puJndiName@"/>
Here's the short explanation:
- A new datasource is deployed (step 1)
- The datasource is referred to in persistence.xml (step 2)
- Add reference to the new persistence unit name in web.xml (step 3)
- Add new property in component.properties which refers to the persistence-unit-ref-name declared in web.xml (step 4)
- The values configured in component.properties is used to configure the managed-persistence-context (step 5)
Note: The entity manager factory is bound to the global JNDI thru "jboss.entity.manager.factory.jndi.name" property configured during step 2, however it is not used... yet :)
3 comments:
Where can I find the component.properties file from point 4?
Post a Comment