Question

How can I achieve "ON DELETE RESTRICT" behavior in a @OneToMany relationship?

AFAIK if I do not set CascadeType.REMOVE the children will not be deleted but the parent will still be removed. I know this cascade type is meant for entity objects but in the database the foreign keys all have "NO ACTION". How can I set the cascade type on database level?

I'm also astonished I did not find anything useful with google regarding this topic?

Was it helpful?

Solution

See comment. "NO ACTION" does what I want. If the delete violates a constraint, it will not be executed and an error is thrown.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top