iberck
9/2/2015 - 11:15 AM

Cascade

Cascade

Cascade

Cascading consists in propagating the Parent entity state transition to one or more Child entities, and it can be used for both unidirectional and bidirectional associations.

Cascading always propagates from Parent to Child entities.

Cascading only makes sense only for Parent – Child associations (the Parent entity state transition being cascaded to its Child entities). Cascading from Child to Parent is not very useful and usually, it’s a mapping code smell.

Hibernate sólo ejecuta las operaciones en cascada cuando es necesario, si la asociación no ha tenido cambios no ejecuta las operaciones.

Cascade remove

Cascade remove significa que al eliminar el objeto padre, se borrarán también los objetos hijo de la base de datos (no confundir con delete-orphan ya que aquí se está borrando el objeto padre).

Recursos

https://vladmihalcea.com/a-beginners-guide-to-jpa-and-hibernate-cascade-types/