Code:
public class A implements Serializable{
protected int aId;
protected List<BInfo> bs = new ArrayList<BInfo>();
protected C c;
public User(){
// Do nothing;
}
@Id
@GeneratedValue
@Column(name="pk_a_id")
public int getAId() {
return aId;
}
public void setAId(int aId) {
this.aId = aId;
}
@OneToOne(mappedBy = "a")
public C getC() {
return c;
}
public void setC(C c) {
this.c = c;
}
@OneToMany(cascade = CascadeType.ALL, fetch=FetchType.EAGER)
@Cascade({org.hibernate.annotations.CascadeType.DELETE_ORPHAN})
@JoinColumn (name="fk_a_id")
public List<BInfo> getBs() {
return bs;
}
public void setBs(List<BInfo> bs) {
this.bs = bs;
}
}
public class C implements Serializable{
private int cId;
private A a;
private List<CGroup> CGroups = new ArrayList<CGroup>();
@Id
@GeneratedValue
@Column(name="pk_c_id")
public int getCId() {
return cId;
}
public void setCId(int cId) {
this.cId = cId;
}
@OneToMany(fetch=FetchType.EAGER)
@JoinTable(
name="Csgroups",
joinColumns = { @JoinColumn( name="fk_c_id") },
inverseJoinColumns = @JoinColumn( name="fk_c_group_id")
)
public List<CGroup> getCGroups() {
return CGroups;
}
public void setCGroups(List<CGroup> cGroups) {
this.cGroups = cGroups;
}
@OneToOne
@JoinColumn (name="fk_a_id")
public User getA() {
return a;
}
public void setA(A a) {
this.a = a;
}
So i am receiving a cannot simultaneously fetch multiple bags, hibernate exception. Through the @OneToOne there is one eager in A and One in B but I believe them to be needed. Any ideas on how to get this to work.
Thanks,
- Phil