Function: Whether the object within the annotated field is cascaded. Optional values: Javax.persistence.CascadeType.PERSIST, MERGE, REMOVE, REFRESH, DETACH, all. Choose one or more of these, and the curly braces are not available when you choose one.
| PERSIST |
The persist operation of the Cascade session. Assuming cascade = {Cascadetype.persist} is configured on the @manytomany annotation of the student class and the Teachers field, the Stu1 object is set with a teachers collection (the objects in this collection are transient ), when the Stu1d object is persisted, all transient objects inside the set are cascaded to the database. |
| MERGE |
Cascade merge operation. The truth is ibid. |
| REMOVE |
Cascade remove operation. The truth is ibid. |
| REFRESH |
Cascade refresh operation. The truth is ibid. |
| DETACH |
Cascade evict operations. The truth is ibid. |
| All |
Cascade all actions above.
|
Or: Use Hibernate's own cascadetype. Optional values:
ALLIncludes all types listed here. |
DELETECorresponds to the Hibernate native DELETE action. |
DELETE_ORPHANDeprecated. Use @OneToOne (orphanremoval=true) or @OneToMany (orphanremoval=true) |
DETACHCorresponds to CascadeType.DETACH . |
EVICTDeprecated. Use CascadeType.DETACH |
LOCKCorresponds to the Hibernate native LOCK action. |
MERGECorresponds to CascadeType.MERGE . |
PERSISTCorresponds to CascadeType.PERSIST . |
REFRESHCorresponds to CascadeType.REFRESH . |
REMOVECorresponds to CascadeType.REMOVE . |
REPLICATECorresponds to the Hibernate native REPLICATE action. |
SAVE_UPDATECorresponds to the Hibernate native save_update (direct reattachment) action. |
Visible, in addition to replicate and save_update is not in the Jpa.cascadetype, the others are the same. Where the DELETE corresponds to Jpa.cascadetype's Remove,delete_orphan is not in favor of, Detach and evict correspond to the detach of Jpa.cascadetype, which is the function of Org.hibernate.Session evict method.
REPLICATE:
Save_update:
Jpa. All of the enumeration values for Cascadetype correspond to the Org.hibernate.Session method (detach corresponds to evict). For the session method, refer to the other side of the blog: http://www.cnblogs.com/565261641-fzh/p/6658747.html
Hibernate a pair of one or one-to-many, many-to-many annotation Cascade properties summary