Is it possible to load entities without ancestor in the middle of a transaction?

27 views
Skip to first unread message

Mihail Lesikov

unread,
Jun 21, 2013, 9:32:19 AM6/21/13
to twig-p...@googlegroups.com
Hi, John

I need to load some entities without ancestor in the middle of a transaction.

I found that in objectify documentation.


.....

Escaping Transactions

There are often times in the middle of a transaction when you would like to make a datastore request outside of a transaction. Perhaps you wish to make a query without an ancestor(), or perhaps you wish to load an entity without enlisting it in a XG transaction.

Objectify makes it easy to run operations outside of a transaction:

ofy().transact(new VoidWork() {
   
public void vrun() {
       
Thing thing = ofy().load().key(thingKey).get();
       
Other other = ofy().transactionless().load().key(thing.otherKey).now();
       
if (other.specialState) {
            thing
.modify();
            ofy
().save().entity(thing);
       
}
   
}
});

This circumstance doesn't come up often but it does come up.

.......




Is there any way of doing this with twig ?  

Thanks.

John Patterson

unread,
Jun 21, 2013, 8:53:44 PM6/21/13
to twig-p...@googlegroups.com
You could create another ObjectDatastore but if any entities are already loaded in the first OD, they will be created as new instances and loaded again.  There is currently no way to "pause" a transaction in the same OD.  Perhaps that would be a useful feature to add.  


--
You received this message because you are subscribed to the Google Groups "twig-persist" group.
To unsubscribe from this group and stop receiving emails from it, send an email to twig-persist...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages