Hi,
Does anyone know if it is possible to create an EntityManagerFactory if you can create EntityManager's that use JTA without using an EJB Session bean?
Can I do
Code:
EntityManagerFactory emf =
Persistence.createEntityManagerFactory("ds");
In a normal java class for a persistence unit ds (for example)
Code:
<persistence-unit name="ds">
<jta-data-source>java:DefaultDS</jta-data-source>
<properties>
<property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/>
<property name="hibernate.connection.username" value="sa"/>
<property name="hibernate.connection.password" value=""/>
<property name="hibernate.connection.url" value="jdbc:hsqldb:."/>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
</properties>
</persistence-unit>
Because when I try to do the following on JBoss I get the message:
Code:
javax.persistence.PersistenceException: org.hibernate.HibernateException: The chosen transaction strategy requires access to the JTA TransactionManager
org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:720)
org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:121)
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
i.e. I am not allowed create the EntityManagerFactory referencing a persistence unit that uses JTA?
Any ideas?
Thanks