Hello,

I would like to build an web application where the entity relationship looks
like as follow:

User 1 -> * Possibility * -> 1 Country
       1 -> 1 Profile * -> 1 Country

............ *initialization and persistence*

User.getPossibilities().add(Possibility);Possibility.setCountry(Country);
User.setProfile(Profile);Profile.setCountry(Country);

em.persist(User);

............ *I got this error below*
WARNING: Exception:Detected attempt to establish CPossibility(no-id-yet) as
the
parent of CUser(46)/CProfile(47)/CCountry(48) but the entity identified by
CUser
(46)/CProfile(47)/CCountry(48) is already a child of
CUser(46)/CProfile(47).  A
parent cannot be established or changed once an object has been persisted.

Does this concept goes against the GAE datastore hierarchy  ?

There are many situation when we have to share the same locations among the
individual object.

What is the real solution on this issue ?
Thanks in advance.

cscsaba

*PS:Implementation of the entities*
....................................... CUser
@Entity
public class CUser {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name="USER_ID")
    private Key Id;
    private String email;

    @OneToMany(cascade = CascadeType.ALL)
    private List<CPossibility> Possibilities = new
ArrayList<CPossibility>();

    @OneToOne(fetch = FetchType.LAZY,cascade = CascadeType.ALL)
    private CProfile Profile;
....................................... CPossibility
@Entity
public class CPossibility {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name="POSSIBILITY_ID")
    private Key id;
    private String name;

    @ManyToOne(fetch = FetchType.LAZY,cascade = CascadeType.ALL)
    private CCountry country;
....................................... CProfile
@Entity
public class CProfile {
        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        private Key id;
        private String phone;

        @ManyToOne(fetch = FetchType.LAZY,cascade = CascadeType.ALL)
        private CCountry country;

....................................... CCountry
@Entity
public class CCountry {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Key id;
        private String name;

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