1
- 在本例中,是否有任何表元素正在被另一个客户端更改,或者只有当我们更改的元素已被另一个客户端更改时,才抛出异常?
只是为了验证 - 从
commit()
抛出的异常不是吗?GAE事务异常PersistenceManager pm = PMF.get().getPersistenceManager(); try { pm.currentTransaction().begin(); List<Row> Table = (List<Row>) pm.newQuery(query).execute(); Table.get(0).setReserved(true); // <----- we change only this element pm.currentTransaction().commit(); } catch (JDOCanRetryException ex) { pm.currentTransaction().rollback() // <----- if Table.get(1) was changed by another client do we get to this point??? }
很酷谢谢杰森! – bach 2010-04-02 01:31:16