Hi Thomas,
I'm working on the same issue for a while - asking this many times here without
a clear answer or solution. What I have found out so far, you can do (assuming
you have a PU "default" in your persistence.xml):
| Map<String,String> map = new HashMap<String,String>();
| map.put( "hibernate.hbm2ddl.auto", "update");
| map.put( "hibernate.dialect", "org.hibernate.dialect.Oracle9Dialect");
| map.put( "hibernate.connection.provider_class",
"org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider");
| map.put( "hibernate.cache.provider_class",
"org.jboss.ejb3.entity.TreeCacheProviderHook");
| map.put( "hibernate.treecache.mbean.object_name",
"jboss.cache:service=EJB3EntityTreeCache");
|
| // ignored - set explicit below
| // map.put( "javax.persistence.jtaDataSource", "java:/anotherDS");
|
| InitialContext jndi = new InitialContext();
| DataSource ds = (DataSource) jndi.lookup( "java:/anotherDS");
|
| Ejb3Configuration cfg = new Ejb3Configuration();
| cfg.setDataSource( ds);
|
| // this works ! tables in db are created.
| // but using returned em later result in a "no transaction" exception.
| EntityManagerFactory emf = cfg.createEntityManagerFactory( "default", map);
|
|
| EntityManager em = emf.createEntityManager();
| // error !
| em.persist( ...);
|
as far as I understand, with this you can only get an application managed em
(non JTA), where you have to begin and commit your tx yourselve. It is not an
container managed em.
so I guess this requierement is not covered in ejb3 yet, although it is imho
usual and important.
andy
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3951861#3951861
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3951861
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user