Hi, Good morning!
I am seeing a strange interaction between cglib, hibernate & what I'm trying to do in my code. My mapped object has a list member variable with access="field". I am not able to update the list with new objects. Here are the details -
mapped classes - A, B, C
A has a member variable of type B, and mapping for A has <many-to-one> B
B has a member variable of type List<C>, and mapping for B has a <list> element with <many-to-many> reference to C
C's mapping has just base java data types.
What I'm trying to do is to add new C's to B's list.
Here's what the code tries to do -
A aobj = session.open(id, A.class); <-- retrieves successfully from db
B bobj = A.getB(); // <--- retrieves successfully from db
List clist = A.getEditor().getList(); // <-- returns PersistentList
C cobj = new C();
clist.add(cobj);
session.insert(cobj); // <-- works, can see sql insert
session.update(bobj); // <-- nothing happens??? doesn't generate any sql
session.update(aobj);
The funny thing is, when I view the bobj object in eclipse, it shows up as CGLIB blah blah blah, and the list member variable is null. Somehow the list is not null when I access it through the getEditor() innerclass which returns the list.
So basically I'm trying to update the collection member of a persistent object. The object being added to the collection is being persisted with the insert but the mapping is not being saved. Its as if hibernate considers the object to be clean.
At the time of session.update(bobj) the member variable for the list bobj is still null and it says its of type cglib.....
Thanks! Everything else works beautifully.
Best Regards,
Ram
|