Hi,
I have the following problem. We have two entities A and B, B have a FK to A (B -> A), so A is the parent in this relationship. In my hbms for A and B I have this:
A.hbm.xml
Code:
<set name="bSet" inverse="true" lazy="true" table="B_TABLE" cascade="all">
<key column="bColumn" />
<one-to-many class="foo.B" />
</set>
B.hbm.xml
Code:
<many-to-one name="aEntity" column="aColumn" class="foo.A"
not-null="true" cascade="none" />
If i try the next pseudocode, it returns an exception saying (null or transient etc, i haven't the trace here):
Code:
// Code for starting transaction
A aObj= new A();
B bObj= new B();
bObj.setAEntity(aObj);
aObj.setBSet(new HashSet<B>());
aObj.getBSet().add(bObj);
session.saveOrUpdate(aObj);
session.flush();
// Code for finishing transaction
Any help would be appreciated, we are using hibernate 3.0.5
Thanks in advance.