drj wrote:
mebi wrote:
...
but when I assign a Book to a Person and then I want to delete that person (the delete is done in a separate action and transaction), the person entity will be deleted and the book entity's foreign key will be set to null ...
And what, may I ask, did you expect to happen?
As you see, the cascade on the parent side is
none, so when I delete a Person(parent side here), Hibernate shouldn't delete the one side, and then it must alert me.
But, when I don't mention the one side(my relation is unidirectional with <many-to-one/> tag only, which has a cascade=
none) when I want to delete the one side I'll get a HibernateException for constaint failure(the foreign key constraint violation).
I want to say that in any case when I set the cascade=
none, the delete action of parent must cause an exception to be thrown, because when I set cascade=
none, Hibernate supposed to don't react in a save-update manner, but here it reacts in save-update manner.
I want to have a bidirectional one-2-many association, and when I want to delete the parent (which has at least one child), the hibernate throws an exception about foreign key constraint violation. I don't want hibernate delete the parent side and update all the children's foreign key to null. So what should I do?