Hibernate version: 3.0.5
Hi,
Another problem we have to overcome. Imagine we have two entities A and B, A is the parent entity and B the child (FK to A). If i have the following code and execute it, it prints "EMPTY SET !!!!!!!!!!!!!!!!", which is the explanation for this?:
Code:
// transaction already started
A aObj= new A();
aObj.setBSet(new HashSet<B>());
session.saveOrUpdate(aObj);
session.flush();
B bObj= new B();
bObj.setA(aObj);
session.saveOrUpdate(bObj);
session.flush();
Long idA= aObj.getId();
// transaction already finished
// some other code (for example code from an struts action)
// transaction already started
A aObjReturned= session.get(A.class, idA);
if (aObjReturned.getBSet().size()== 0)
System.out.println("EMPTY SET !!!!!!!!!!!!!!!!");
// transaction already finished
Thanks in advance