views:

38

answers:

1

Hi,

  1. In this example, is the exception being thrown if any of the table elements are being changed by another client, or only if the element that we changed has been changed by another client?
  2. Just to verify - the exception is thrown from the commit() isn't it?

    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??? 
    }
    
+1  A: 

1.) An exception will only be thrown if that entity is modified elsewhere during the transaction.

2.) Correct, the exception will be thrown when you commit.

You'll also have to call pm.makePersistent(Table.get(0)) to have it save your change.

Jason Hall
cool thanks Jason!
bach