I have written a unit test for appengine 1.2.8 with JDO and eclipse 3.5. You can see them at the bottom of the message.
Here is my model: Class A <---One to many bidi---> B ---One to many--- > C ---One to One---> D 1- My first test generates a "can't update the same entity twice in a transaction or operation" although I don't do several updates. Strangely, it works if I don't update the email field of object A, or if I change the private member variable "_expList" in object A by "_aList"... 2- Test 2 fails with "can't operate on multiple entity groups in a single transaction." although I *should* have a single entity group where C is an indirect child of A. It seems to work if I use a List of C instead of a Set of C within class B. It also works if I manually set the Key of object C or if I don't insert object A first in database. 3- Fails because when I use loadByKEy, my list of B is not filled (whereas the object returned by update() is filled). In the same way, I can't get a request working, all are returning null. However a fetch plan with a depth of 3 and defaultFetchGroups are defined. This was working in appengine 1.2.1. Links to the eclipse project (just need to import it) and another with just the source: http://www.mediafire.com/file/eeu0ldvzwll/TestGAE_full.zip http://www.mediafire.com/file/zzjyuhdwzzy/TestGAE_src.zip Extract: private final A initAinDatabase(String pFirstName, String pLastName, String pEmail) throws DaoException { A a = new A(pFirstName, pEmail); A newA = _aDao.create(a); assertAEquals(newA, a); return a; } public final void testBug() throws DaoException { A a = initAinDatabase("Dupont", "Pierre", "[email protected]"); D skill = new D(); C skillUpdate = new C(skill, 3);// Works if i write new C (null, 3) B experience = new B(); experience.addCUpdate(skillUpdate); a.setEmail("");// Works if I write setFirstName(""); a.addB(experience); _aDao.update(a); // FIXME Here I get a // org.springframework.orm.jdo.JdoSystemException: can't update the same // entity twice in a transaction or operation; nested exception is // javax.jdo.JDOException: can't update the same entity twice in a // transaction or operation } public final void testBug2() throws DaoException { // If I create the object A instead on inserting it in database, it also works A a = initAinDatabase("Dupont", "Pierre", "[email protected]"); B experience = new B(); a.setEmail(""); a.addB(experience); a = _aDao.update(a); D skill = new D(); C skillUpdate = new C(skill, 3); a.getBList().get(0).addCUpdate(skillUpdate); a = _aDao.update(a); // FIXME Here I get a // DaoException: javax.jdo.JDOFatalUserException: Illegal argument // NestedThrowables: // java.lang.IllegalArgumentException: can't operate on multiple entity // groups in a single transaction. found both Element { // type: "A" // id: 1 // } // and Element { // type: "C" // id: 3 // } } public final void testBug3() throws DaoException { A a = initAinDatabase("Dupont", "Pierre", "[email protected]"); B experience = new B(); experience.setString("Tooto"); a.addB(experience); A a2 = _aDao.update(a); a = _aDao.loadByKey(a.getKey()); D skill = new D(); C skillUpdate = new C(skill, 3); // FIXME Here I have an IndexOutOFBoundException / Index 0 Size 0 a.getBList().get(0).addCUpdate(skillUpdate); a = _aDao.update(a); } @PersistenceCapable(identityType = IdentityType.APPLICATION, detachable="true") public class A { private static final long serialVersionUID = 7061281232540895192L; @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Key _key; @Persistent private String _firstName; @Persistent private String _email; @Persistent(mappedBy="_parent", defaultFetchGroup="true") private List<B> _expList; ... @PersistenceCapable(identityType = IdentityType.APPLICATION, detachable="true") public class B { private static final long serialVersionUID = 829289483086117887L; @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Key _key; @Persistent private String _string; @Persistent(defaultFetchGroup="true") private A _parent; @Persistent(defaultFetchGroup="true") private Set<C> _cUpdates; ... @PersistenceCapable(identityType = IdentityType.APPLICATION, detachable="true") public class C { private static final long serialVersionUID = -5806378892487300728L; @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Key _key; @Persistent private int _level; @Persistent(defaultFetchGroup="true") private D _sList; ... @PersistenceCapable(identityType = IdentityType.APPLICATION, detachable="true") public class D { private static final long serialVersionUID = -6630402708475167158L; @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Key _key; @Persistent @Unique private String _name; Please any help is welcomed or I'll get bald by the of the day! :D -- 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.
