Transaction rollback behavior

Showing 1-2 of 2 messages
Transaction rollback behavior Kyle 6/16/09 7:59 AM
Maybe I'm missing something, but I'm unable to rollback a transaction
that *inserts* a record. I have the following code:

Transaction tx = pm.currentTransaction();
try {
    tx.begin();
    Counter counter;
    try {
                counter = (Counter)pm.getObjectById(Counter.class, key);
        } catch(JDOObjectNotFoundException e) {
                counter = new Counter(key);
        }
        counter.setValue(counter.getValue() + amount);
        pm.makePersistent(counter);
} finally {
    tx.rollback();
}

If I pass in an existing key, everything works as expected, rolling
back to the original value. However, when I pass in a new key (causing
a new Counter to be created), the rollback doesn't seem to affect the
new key (it's inserted regardless, and remains even after the
rollback). I assumed that rolling back the transaction would revert
the insertion. Anyone able to shed some light on this behavior?

Kyle
Re: [appengine-java] Transaction rollback behavior jrray 6/16/09 5:53 PM
If you're trying this in the development environment, be advised that
the development environment does not support transactions.

Your new Counter entity is saved to the datastore as soon as
makePersistent runs, and rollback is a no-op.

http://groups.google.com/group/google-appengine-java/browse_thread/thread/75e19ab057483be3

http://code.google.com/p/datanucleus-appengine/issues/detail?id=56