Joined: Tue Apr 20, 2010 6:42 am Posts: 2
|
I have the following scenario: class A{ List<B> listB; C objC; } class C{ B objB; //References 'B' } class B{ }
Mapping: <hibernate-mapping> <class name="A" table="A"> <bag name="listB" table="AB" cascade="all,delete-orphan"> <key column="AId"/> <many-to-many class="B" column="BId" unique="true"/> </bag> <many-to-one name="objC" column="CId" unique="true" not-null="false" cascade="all"/> </class> <class name="B" table="B"> </class> <class name="C" table="C"> <many-to-one name="objB" class="B" column="BId" not-null="true" unique="true" /> </class> </hibernate-mapping>
Now I have following code. A objA = new A(); B objB = new B(); C objC = new C(); objA.listB.add(objB); objA.objC = objC; objC.objB = objB; save(objA);// Get not-null property references a null or transient value: C.objB
Why am I getting this exception? Why can't hibernate store both objB and objC together?
|
|