I am currently moving a (working) application using EclipseLink in Hibernate JPA, basically it went pretty smoothly, but I find one that I can’t explain, and also can’t come up with a good condition search!
Basically, I have four objects with one-to-many relationships forming a chain:
EntityA has an EntityB list, each of which has an EntityC list, each of which has an EntityD list
each of them has a many-to-one relationship going the other way, therefore:
EntityD has EntityC, which has EntityB, which has EntityA.
This (greatly reduced for clarity):
@Entity
public class EntityA {
@OneToMany (cascade = CascadeType.All, mappedBy = "entityA")
private List<EntityB> entityBList;
...
}
@Entity
public class EntityB {
@OneToMany (cascade = CascadeType.All, mappedBy = "entityB")
private List<EntityC> entityCList;
@JoinColumn (name = "ENTITY_A", referencedColumnName = "ENTITY_A_ID")
@ManyToOne (cascade = CascadeType.PERSIST, optional = false)
private EntityA entityA;
}
@Entity
public class EntityC {
@OneToMany (cascade = CascadeType.ALL, mappedBy = "entityC")
private List<EntityD> entityDList;
@JoinColumn (name = "ENTITY_B", referencedColumnName = "ENTITY_B_ID")
@ManyToOne (cascade = CascadeType.PERSIST, optional = false)
private EntityB entityB;
}
@Entity
public class EntityD {
@JoinColumn (name = "ENTITY_C", referencedColumnName = "ENTITY_C_ID")
@ManyToOne (cascade = CascadeType.PERSIST, optional = false)
private EntityC entityC;
}
EntityA ( ) , , EntityA, PersistentBag List<EntityB>. , , List<EntityB> EntityCs EntityB.
, , EntityA, B C, , EntityD EntityC , null.
- , EntityA, , EntityC, "entityDList", null.
, , :
EntityManager.refresh(entityC);
, PersistentBag entityDList.
, , Hibernate 2 ( 3, , ), , , . -?
- , .refresh? - , Hibernate ?