views:

41

answers:

1

Hi,

Say you have a Client Buying Card object and a product object. When the client chooses the buy opition you create the object and then add a product. It should be transactional but it's not on the same entity group as the product and the card already been persisted, isn't it? Is there any way to overcome this simple scenario safely and easily?

here's a code sample:

Transaction tx = pm.currentTransaction();
tx.begin();
Product prod = pm.getObjectById(Product.class, "TV");
prod.setReserved(true);
pm.makePersistent(prod);

Card card = pm.getObjectById(Card.class, "user123");   /// <--- will thorw an exception as card and prod aren't on the same entity group
card.setProd(prod);
pm.makePersistent(card);
try {
    tx.commit();
    break;
}
+1  A: 

This blog post may be helpful: http://blog.notdot.net/2009/9/Distributed-Transactions-on-App-Engine

(Even though the examples are in Python, the concept is exactly the same)

Jason Hall
Bah, you got there first. ;)
Nick Johnson
You got there more than 6 months ago! :)
Jason Hall