Quote:
PostPosted: Wed Nov 30, 2005 3:06 am Post subject:
If you had mapped Asset in Hibernate as well, you would work the other way round: set the association to AssetOwner to null programmatically, and let Hibernate decide to delete the AssetOwner via a cascade="delete-orphan".
Well that's not really how the UI works. A user can delete an AssetOwner at any point, and when that happens I need to set all Assets owned by that AssetOwner to NULL. I was wondering if I could add some mappings to AssetOwner to give it hints about Asset's foreign key without having to explicitly map Asset. And when I delete AssetOwner it would know to do something like:
update Asset set AssetOwnerID=null where AssetOwnerID=?
From reading the documentation it sounds like Hibernate would do that if I had mapped out Asset. I just don't know if it would do it when I haven't mapped Asset.
Right now I'm doing manual SQL which is my least favorite, but I know I'm in a funny situation in the way I'm using hibernate.
Thanks for your help
Charlie