You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can use in a parent entity, when you delete children from the list, then the children records are actually deleted from the database by JPA using genrated queries. Currently there are no cases for Orphan Removal
ON DELETE CASCADE
You can use in a child entity. it affects the actual generated schema. When you delete parent entity, then child entities are automatically deleted by the database Applied ON DELETE CASCADE
https://www.jpa-buddy.com/blog/best-practices-and-common-pitfalls/
https://blog.sapzil.org/public/springcamp2019.pdf
https://stackoverflow.com/questions/7197181/jpa-unidirectional-many-to-one-and-cascading-delete
https://www.inflearn.com/questions/39769
https://madplay.github.io/post/avoid-n+1-problem-in-jpa-using-querydsl-fetchjoin
https://stackoverflow.com/questions/27106274/jpa-hibernate-on-delete-set-null
https://kapentaz.github.io/jpa/hibernate/@ManyToOne%EC%9D%98-N+1-%EB%AC%B8%EC%A0%9C-%EC%9B%90%EC%9D%B8-%EB%B0%8F-%ED%95%B4%EA%B2%B0/#
https://dabok407.tistory.com/73
Setup cascade properly
https://www.baeldung.com/jpa-cascade-remove-vs-orphanremoval
https://stackoverflow.com/questions/14875793/jpa-hibernate-how-to-define-a-constraint-having-on-delete-cascade
https://thorben-janssen.com/avoid-cascadetype-delete-many-assocations/
https://www.bezkoder.com/spring-boot-unit-test-jpa-repo-datajpatest/
Orphan Removal
You can use in a parent entity, when you delete children from the list, then the children records are actually deleted from the database by JPA using genrated queries.
Currently there are no cases for Orphan Removal
ON DELETE CASCADE
You can use in a child entity. it affects the actual generated schema. When you delete parent entity, then child entities are automatically deleted by the database
Applied ON DELETE CASCADE
ON DELETE SET NULL
http://www.yannlaviolette.com/2013/09/jpa-hibernate-on-delete-set-null.html
Only @PreRemove approach is available
but if you don't want to use @onetomany you just have set null manually
Decided to use the manual approach
Use Transactional annotation properly
https://www.podo-dev.com/blogs/285
https://velog.io/@ddongh1122/Spring-Transactional-%ED%81%B4%EB%9E%98%EC%8A%A4-%EB%82%B4%EB%B6%80-%ED%98%B8%EC%B6%9C-%EB%AF%B8%EC%9E%91%EB%8F%99-%EC%9D%B4%EC%8A%88
https://stackoverflow.com/questions/4396284/does-spring-transactional-attribute-work-on-a-private-method
https://medium.com/javarevisited/spring-transactional-mistakes-everyone-did-31418e5a6d6b
Handle JPA errors properly
https://stackoverflow.com/questions/52456783/cannot-catch-dataintegrityviolationexception
https://www.baeldung.com/hibernate-initialize-proxy-exception
https://www.podo-dev.com/blogs/278
https://stackoverflow.com/questions/50150647/handling-exceptions-during-a-transactional-method-in-spring
Use approaches like AOP, inheritance, composition or callback methodsDecided to use AOP approach
TODOs
Use MappedSuperclass or Embedded annotationUse Entity inheritanceThe text was updated successfully, but these errors were encountered: