I have a simple class where the key needs a Parent and auto generated
long id component.
I am not sure hot to implement this with JPA/JDO, here is a hack I
tried:

@Entity
public class Account {
  @Id
  private Key key;
..
}

Account account = new Account();
account.setKey(DatastoreServiceFactory.getDatastoreService().allocateIds(parent.getKey(),
Account.class.getSimpleName(), 1).getStart());
em.persist(account);

This seems to work, but I am wondering if there is a more elegant way?

-g.

PS: Remember, I need an auto-generated Id *with* a parent.

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

Reply via email to