Hi All
I have a Folder object. This folder object has children folders like this:
Code:
<set name="subFolders" cascade="delete" order-by="N">
<key column="ParentFolderUUID" />
<one-to-many class="com.myCompany.file.Folder" />
</set>
In my service layer I supply security. This means if a user may not view a sub folder the sub folder should be removed from the parent folder subFolder set. Like this:
Code:
if (noSecurity)
parentFolder.getSubFolders().remove( subFolder);
If I do this, hibernate updates the subFolder in such a way that it is detached from the parent folder. The thing is, I have set cascade="delete". According to hibernate, cascade="delete" should only delete the sub folders when delete() is called on the parent folder. It shouldnt detach the subFolder in anyway when cascade is set to delete.
It's possible I have misunderstood how hibernate works. In that case, can anybody tell me how can I remove elements from a set or list without hibernate applying changes immediately to the database?
Thanks in advance,
Martyn