In my application I'm using JDO. In some cases, I have un-owned relationships where I explicitly created my own entity group because I need to be able to do transactions with a group of records. For instance;
@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true") public class Customer { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Long customerId = null; ... } @PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true") public class User { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Key userId = null; @Persistent(defaultFetchGroup="true") private Long customerId = null; // foreign-key for Customer ... } When I persist a User, I set the parent part of the userId key, then let JDO fill in the id portion when I call save(). This all works well. However, sometimes I want to query a set of User's by the Customer's id. As you can see above, I've duplicated the customerId in the User record for this purpose. This works fine, but it takes an extra field and creates an extra index. What I'd really like to do is to query the User key's parent part so I can save an index, which could add up over time. I already have records in a production database that have the above structure, so anything I do needs to be backward compatible. Everything I see in the docs assumes that you are using JDO to maintain owned relationships, but I'm not doing that. I've tried using the 'parent-pk' field Datanucleus extension in a query where I create a full Customer Key from the customerId field, but I get an exception. I believe this is because this 'virtual' field is created by JDO only for owned relationships (but that is just a guess). Is there an explicit way within JDO to do an ancestor query using the parent key if you are using unowned relationships? -- 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-j...@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.