I think the problem is that you are updating the inverse end of a bi-directional association. The hibernate documentation says:
Quote:
Changes made only to the inverse end of the association are not persisted
This is at
http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#collections-bidirectionalIn a bi-directional one-to-many association the inverse end must be the "many" end. So to get the desired result you have to update the "one" end of the association. The following code does this:
Code:
Transaction transaction = null;
Session session = HibernateUtil.currentSession() ;
transaction = session.beginTransaction();
TABLE1 table1 = (TABLE1)session.load(TABLE1.class,1);
Set l = table1.getStories();
try
{
Iterator i = l.iterator();
while(i.hasNext())
{
((TABLE2)i.next()).setParent(null);
}
// table1.setStories(l);
//session.save(table1);
transaction.commit();
}
In the code above we are updating the "one" end of the bi-directional association by setting TABLE2.parent to null.
The hibernate documentation also says:
Quote:
Mapping one end of an association with inverse="true" doesn't affect the operation of cascades, these are orthogonal concepts!
So I expect that the associated TABLE2 objects will be deleted because of the cascade option for TABLE1.stories is set to all-delete-orphan.
I hope that helps (and works!).
Cheers