문제

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?

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top