开发者

Container Managed Transaction with JDO/DataNucleus

开发者 https://www.devze.com 2023-02-08 15:04 出处:网络
Goodmorning all, I\'m currently playing with Datanucleus/JDO. One thing that I like is the Type safe query system, and I want to use Datanucleus in future projects (I come from Hibernate background).

Goodmorning all,

I'm currently playing with Datanucleus/JDO. One thing that I like is the Type safe query system, and I want to use Datanucleus in future projects (I come from Hibernate background). I want to let the container (JBOSS 5) manage the transaction and I've defined a data source following the instructions from a datanucleus user (datanucleus forum thread), the only problem is that i cannot understand how to get a JDOPersistenceManager, all i get from a jndi lookup is the PersistenceManager, if I try a cast to JDO开发者_如何学JAVAPersistenceManager i will get ClassCastException. I need the JDOPersistenceManager to get a typesafe query... My configuration is the same as the one explained in the thread..

Does someone encountered the same problem before? And I wander also IF this thing would be possible at all...

Thank you for the replies!


Never had the time to try it under JCA so no obvious access point for getting the underlying JDOPersistenceManager ... however, try something like this

JDOPersistenceManager jdopm = 
    ((JDOTransaction)pm.getCurrentTransaction()).getPersistenceManager();

and if that works then you have a workaround until we provide an accessor in the org.datanucleus.jdo.connector.PersistenceManagerImpl class for the JDOPersistenceManager

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号