Hello guys,

I am trying to create a simple to-do API service via App Engine. I have 
Userdata objects that have a set of 
Project data objects and these Project data objects have a set of Taskobjects. 
The following code should give you some idea about their 
implementation and relationships.

@PersistenceCapable(detachable = "true")
public class User implements Serializable {
 @PrimaryKey
 @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
 private Long id;

 @Persistent(mappedBy = "user")
 private List<Project> projects;
}


@PersistenceCapable(detachable = "true")
public class Project implements Serializable {
 @PrimaryKey
 @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
 private Key id;
 
 @Persistent
 private User user;

 @Persistent(mappedBy = "project")
 private List<Task> tasks;
}


@PersistenceCapable(detachable = "true")
public class Task implements Serializable {
 @PrimaryKey
 @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
 private Key id;

 @Persistent
 private Project project;
}

What I am doing with User data object is the following (EntityManager is 
defined as it is shown on App Engine help pages):
EntityManager em = EMFService.get().createEntityManager();
try {
 User dev = em.find(User.class, id);
 em.remove(dev);
} finally {
 em.close();
}

*What I want to do is to get Project and Task data objects by their id, 
which is the long number that corresponds to the data object not the key 
combination with its parent that refers to the object as well. Since these 
objects are child of others, I could't figure out how to get them by their 
id value.*

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-appengine/-/rDty6kFTP6YJ.
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?hl=en.

Reply via email to