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