3.2.5.4. Transitive persistence with cascading
You probably have noticed the
cascade attribute taking an array of CascadeType as a value. The cascade concept in EJB3 is very is similar to the transitive persistence and cascading of operations in Hibernate, but with slightly different semantics and cascading types:
- CascadeType.PERSIST: cascades the persist (create) operation to associated entities persist() is called or if the entity is managed
- CascadeType.MERGE: cascades the merge operation to associated entities if merge() is called or if the entity is managed
- CascadeType.REMOVE: cascades the remove operation to associated entities if delete() is called
- CascadeType.REFRESH: cascades the refresh operation to associated entities if refresh() is called
- CascadeType.ALL: all of the above
Note
CascadeType.ALL also covers Hibernate specific operations like save-update, lock etc... Check Section 3.4.7, “Cascade” for more information
Please refer to the chapter 6.3 of the EJB3 specification for more information on cascading and create/merge semantics.