I tried your suggestion. The new Structure looks like this:
Code:
@Entity(name="GroupNode", access = AccessType.FIELD)
@Table(name="GroupNode")
public class GroupNode {
@Id
@Column(name="`ID`", length=100)
public String ID = new String();
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
@JoinColumn(name="ChildGroupID")
public Set<GroupNodeRelationship> Parents = new HashSet();
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
@JoinColumn(name="ParentGroupID")
public Set<GroupNodeRelationship> Children = new HashSet();
}
Code:
@Entity(name="GroupNodeRelationship", access = AccessType.FIELD)
@Table(name="GroupNodeRelationship")
public class GroupNodeRelationship {
@Id
@Column(name="`ID`", length=100)
public String ID = new String();
@ManyToOne(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
@JoinColumn(name="ChildGroupID", insertable=false, updatable=false)
public GroupNode ChildGroupObject = null;
@ManyToOne(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
@JoinColumn(name="ParentGroupID", insertable=false, updatable=false)
public GroupNode ParentGroupObject = null;
@OneToOne(cascade = CascadeType.ALL, fetch=FetchType.EAGER)
@JoinColumn(name="`ParentGroupThatOwnsThisLeaf`")
public GroupNode GroupOwner = null;
}
Now, when I make a query to retrieve GroupNodeRelationship records, ChildGroupObject , ParentGroupObject , GroupOwner is not filled ! OneToMany works but with the same structure, ManyToOne is not filling the right Feilds!