开发者

How to detect a pending JDO transaction?

开发者 https://www.devze.com 2023-01-01 22:59 出处:网络
I believe I am getting JDO commit Exceptions due to the transactions nesting although I\'m not sure. Will this detect the situation where I am starting a transaction when another is pending?开发者_JA

I believe I am getting JDO commit Exceptions due to the transactions nesting although I'm not sure.

Will this detect the situation where I am starting a transaction when another is pending?

开发者_JAVA百科
 PersistenceManager pm = PersistenceManagerFactory.get().getPersistenceManager();
 assert  pm.currentTransaction().isActive() == false  : "arrrgh";
 pm.currentTransaction().begin();

Is there a better or more reliable way?


courtesy of Ikai Lan (Google)

You can't detect whether a transaction is active. The reason is that datastore entity groups are not pessimistically locked: they are optimistically locked. That is, the checking for whether your application operated on stale data is checked at write time, not at data read time.

0

精彩评论

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