I am working with App Engine since couple of days. The most important for me now is modeling data, so I have some question about that.
Let's say that I have simple MyUser
class. I have Buddy
class as well which looks like that:
@Entity
public class Buddy {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Key id;
private Date createAt;
private MyUser user;
private Key buddyOf;
}
In this class I have MyUser
field because every buddy is an user and I have buddyOf field because there is another MyUser which has this buddy on his buddy list.
The question is If I get from Datastore one sample buddy, I get this MyUser
as well? If yes what when in MyUser
class will be embedded another Entity
and in that Entity
one more, etc...? Maybe I should persist only Key
fields to other entities?
The main question is how I should store data in datastore? I should use composition and has objects inside other objects? If yes what with objects in objects in objects, etc...
What is the best approach?