Thanks for making the code available. This looks like an unintentional bug fix to me. There is a hard and fast rule that you can't operate on more than one entity group inside a transaction, so creating and saving two instances of EntityA should always generate an exception because they are both root entities and therefore part of different entity groups. This code _should_ have thrown an exception in 1.3.0 (and earlier), but it didn't. I made some implementation changes to how transactions are managed in 1.3.1 and it looks like I fixed this problem as part of it.
Max On Fri, Feb 12, 2010 at 12:10 AM, vori <[email protected]> wrote: > The following source code has the same problem. > > --------- > PersistenceManager pm = pmfInstance.getPersistenceManager(); > > pm.makePersistent(new EntityB("key")); // If this two lines are > commented out, > pm.getObjectById(EntityB.class, "key"); // the following code throws > exception on sdk1.3.0 too. > > Transaction tx = pm.currentTransaction(); > tx.begin(); > pm.makePersistent(new EntityA()); > pm.makePersistent(new EntityA()); // it throws exception if it > compiled using sdk1.3.1. > tx.commit(); > --------- > > Full source code is included in the following repository. > Hg repo > https://test-gae-j-sdk-131.googlecode.com/hg/ > Project page: http://code.google.com/p/test-gae-j-sdk-131/ > > On 2月12日, 午後4:25, vori <[email protected]> wrote: > > Sorry, I am wrong. > > I inspected my source code and found the real cause. > > > > The following code can works on SDK1.3.0, but it throws > > "java.lang.IllegalArgumentException: > > can't operate on multiple entity groups in a single transaction." > > when it used on SDK1.3.1. > > > > ---- > > PersistenceManager pm = pmfInstance.getPersistenceManager(); > > > > pm.makePersistent(new EntityB("key")); // If this two lines are > > commented out, > > pm.getObjectById(EntityB.class, "key"); // the following code throws > > exception on SDK1.3.0 too. > > > > ArrayList<EntityA> entities = new ArrayList<EntityA>(2); > > entities.add(new EntityA()); > > entities.add(new EntityA()); > > Transaction tx = pm.currentTransaction(); > > tx.begin(); > > pm.makePersistentAll(entities); // it throws exception if it compiled > > using sdk1.3.1. > > tx.commit(); > > ---- > > > > Full source code is here.https://test-gae-j-sdk-131.googlecode.com/hg/ > > > > On 2月12日, 午前3:11, "Max Ross (Google)" > > <[email protected]<maxr%[email protected]> > > > > wrote: > > > > > > > > > Assuming a ClassA object with the specified id already exists, the code > > > you've posted works fine for me. Could you put together a complete > example > > > that demonstrates the unexpected behavior? > > > > > Thanks, > > > Max > > > > > On Wed, Feb 10, 2010 at 7:49 PM, vori <[email protected]> wrote: > > > > Is it a bug on JDO of SDK 1.3.1? > > > > > > ------ > > > > PersistentManager pm = PMF.get().getPersistenceManager();; > > > > > > ClassA classA = pm.getObjectById(ClassA.class, "id"); > > > > ClassB classB = new ClassB(); > > > > > > Transaction tx = pm.currentTransaction(); > > > > tx.begin(); > > > > pm.makePersistent(classB); > > > > > > tx.commit(); // It throws "javax.jdo.JDOException: can't operate on > > > > multiple entity groups in a single transaction." > > > > ------ > > > > > > -- > > > > 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]<google-appengine-java%[email protected]><google-appengine-java%2B > [email protected]> > > > > . > > > > For more options, visit this group at > > > >http://groups.google.com/group/google-appengine-java?hl=en. > > -- > 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]<google-appengine-java%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-appengine-java?hl=en. > > -- 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.
