Hello! I came accross the following situation: I am trying to create a DbCustmer object (with a DbContact object as a member/field) from a DbRawContact object, then mark the DbRawContact object so that it will not be processed again next time.
try { for (DbRawContact db : extent) { if (db.getVersion().equals("0.0")) { DbContact newContact = new DbContact(db); DbCustomer customer = new DbCustomer(); customer.setProfile(newContact); Transaction tx = pm.currentTransaction(); try { tx.begin(); pm.makePersistent(customer); db.setVersion("0.1"); tx.commit(); } finally { if (tx.isActive()) { tx.rollback(); } } } } } catch (Exception e) { extent.closeAll(); } extent.closeAll(); I am aware that I can only do transactions "in an entity group". DbCustomer and DbContact will be in the same entity group, but i am aware that DbRawContact is in a different entity group. My question is: why didn't this transaction failed, if cross entity group transactions are not supported? Instead the operation worked and somehow I now have duplicate DbCustomer and DbContact objects in the database. (note: DbRawContact objects contain no duplicates) Below is a snippet of my DbCustomer and DbContact classes and the setProfile() function. @PersistenceCapable(identityType = IdentityType.APPLICATION) public class DbContact extends DbEntity { .... @Persistent private DbCustomer customer; @Persistent private boolean isCustomerProfile; .... @PersistenceCapable(identityType = IdentityType.APPLICATION) public class DbCustomer extends DbEntity { ... @Persistent(mappedBy = "customer") @Order(extensions = @Extension(vendorName="datanucleus", key="list- ordering", value="isCustomerProfile desc")) private List<DbContact> contacts; .... (i also ran across the problem that i can't have both owed "1-to-many" and "1-to-1" relationships between the same two object types in JDO, so i used a list (1-to-many) relationship like this: - the first element is the "profile" (a "pseudo" 1-to-1 relationship); - the other list elements model the 1-to-many relationship) public void setProfile(Contact contact) { if (contacts == null) { contacts = new ArrayList<DbContact>(); } if (contacts.size() == 0) { DbContact dbContact = new DbContact(contact); contacts.add(dbContact); } else { DbContact dbContact = contacts.get(0); dbContact.setCustomerProfile(true); dbContact.copyEntityInfo(contact); } } --~--~---------~--~----~------------~-------~--~----~ 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 google-appengine-java@googlegroups.com To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en -~----------~----~----~----~------~----~------~--~---