What is the purpose of CascadeType in Spring Data JPA / Hibernate?
BuiltOnJavaScript
Last updated on
Your thoughts?
Share your thoughts
The default CascadeType is no cascade type fyi
The default CascadeType is no cascade type fyi
© 2024 StackChief LLC. All rights reserved.
CascadeType is an option that specifies how related entities should be treated...
let's say you have a one-to-many relationship between courses and students...
in your @Entity class you may have something like:
This is saying that every operation you perform on this entity, every associated entity will get the same treatement,
So if you delete a parent entity all of it's children (associations) will also get deleted.
Sometimes this makes sense. Sometimes it doesn't. BE CAREFUL in using this as it can have unexpected consequences...