I am creating a Cloud Endpoint in Google App Engine with JDO. I have two entities. The User entity contains a list of groups. The group entity contains a list of members which are user entities.
User Entity:
@PersistenceCapable(identityType = IdentityType.APPLICATION) public class USER {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
Key userid;
@Persistent
String name;
@Persistent
private Set<GROUP> groups; //getters setters
Group Entity
@PersistenceCapable(identityType = IdentityType.APPLICATION) public class GROUP {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
Key groupid;
@Persistent
String name;
@Persistent
private Set<USER> members; //getters setters
My API Method
@ApiMethod(name = "INSERT_CIRCLE")
public wmcircle insertcircle(CIRCLE circle) {
PersistenceManager mgr = getPersistenceManager();
try {
if (contains(circle)) {
throw new EntityExistsException("Object already exists");
}
mgr.makePersistent(circle);
} finally {
mgr.close();
}
return circle;
}
When I create a group GAE creates the user entities which the circle owns and sets the relationship but thats not the behavior I want. I want that I can set the relationship to existing user entities.