If I check getObjectById() just before makePersistent(), another thread could still delete it between the two calls couldn't it?
Uses_for_Transactions <http://code.google.com/intl/nl/appengine/docs/java/datastore/transactions.html#Uses_for_Transactions%20> Is exactly the thing. _Except_ not for concurrent updates, but for concurrent update and _deletes_ As far as I can tell, a transaction protects me from concurrent updates but I'm not sure about a concurrent update and _delete_. so tx.begin(); if( persistme != null ){ // Interesting Part-> at this point, suppose another thread (eg servlet) _deletes_ the entity associated with persistme, this could happen right?... persistme.changeSomeValue(); // ...will have just modified an entity another thread has just deleted and then... pm.makePersistent( persistme ); //...won't this still just recreate that same deleted object because the id is now gone and even though I am in a transaction? I certainly do not want that. } tx.commit() I don't want to complicate the story but maybe I need to add that I am not really doing pm.deletePersistent( delme ) in the other thread, I am removing an item from a dependent List (which implicitly deletes). So Servlet B is really doing something like class Company{ ... @Element( dependent = "true" )...etc private List<Employee> employees = new ArrayList<Employee>(); ... remove( persistme ){ employees.remove( persistme ); } } ... tx.begin(); persistme = pm.getObjectById( Employee.class, sameKeyAsOtherServlet ); somecompany.remove( persistme ) tx.commit(); ...etc I understand that this may only be workable by using a flag to indicate "deleted-ness" but I am reluctant to add that complexity if there is anyway to avoid it. -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
