Hibernate a pair of one or one-to-many, many-to-many annotation Cascade properties summary

Source: Internet
Author: User
Tags deprecated

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.