Good afternoon!
I use JPA and Hibernate annotations.
There is a Parent which contains the Child collection. You must delete the Parent, but not delete it Childs.
Here is what I know about it: - cascade determines which function call will be repeated for the child. for example persist, delete, and so on. - if cascade is not specified, then nothing is called.
However, my knowledge diverges from reality. If I do not write a cascade, or if I list all operations except deletion, everything is deleted anyway. Does not help and the use of Hiberneytovskogo cascade.
Code:
@OneToMany() // @org .hibernate.annotations.Cascade( // org.hibernate.annotations.CascadeType.PERSIST // ) @Fetch(FetchMode.JOIN) private Set<Child> childs;
, unidirectional.
Do I understand the use of cascade correctly? How to solve my problem?