Can you try moving your query into the first transaction and report if this
makes a difference?

- Jason

On Fri, Oct 30, 2009 at 7:10 PM, RoryD <[email protected]> wrote:

>
> I'm aware of the restriction on operating on multiple entity groups in
> a single transaction, but I thought the following code would work (but
> it doesnt):
>
> Transaction tx = null;
>
> try {
>        tx = pm.currentTransaction();
>
>        ClassA existing = getExistingByQuery(pm);
>        if(existing != null) {
>                // 1st transaction
>                tx.begin();
>                existing.setStuff("yo");
>                tx.commit();
>
>                if(existing.isDingBat()) {
>                        // 2nd transaction
>                        tx.begin();
>                        ClassB other = new ClassB();
>                        other.setStuff("wow");
>                        pm.makePersistent(other);  // (***)
>                        tx.commit();
>                }
>        }
> } catch (Exception e) {
>        if(tx != null && tx.isActive()) {
>                tx.rollback();
>        }
> }
>
> However, I get an exception at the line marked (***):
> java.lang.IllegalArgumentException: can't operate on multiple entity
> groups in a single transaction.
>
> How do I get another transaction then? Do i need to create a new
> PersistenceManager for the second part?  In this simplified example, I
> could forego the second transaction entirely, but that might not
> always be the case, so what's the general solution?
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to