I'm currently asked to convert our POJOs hibernate annotations to hbm.xml files,
But I came across two annotations that I can't "translate" and doesn't find a complete answer to my question,
What cascading type should I use to reflect the following: 1)
@Cascade({CascadeType.PERSIST, CascadeType.REFRESH, CascadeType.REMOVE, CascadeType.SAVE_UPDATE })
2)
@Cascade({CascadeType.MERGE})
Thanks in advance.
.hbm.xml file have 6 types of cascade annotations.
cascade="none"
- the default type. It tells Hibernate to ignore the associations. cascade="save-update"
- that type tells Hibernate to navigate the association when the transaction is committed and when an object is passed to save() or update() and save newly instantiated transient instances and persist changes to detached instances. cascade="delete"
which tells Hibernate to navigate the association and delete persistent instances when an object is passed to delete(). cascade="all"
- which tells Hibernate to cascade both save-update and delete, as well as calls to evict and lock. cascade="all-delete-orphan"
means the same as cascade="all" but, in addition, Hibernate deletes any persistent entity instance that has been removed (dereferenced) from the association (ie: from a collection). cascade="delete-orphan"
tells Hibernate to delete any persistent entity instance that has been removed (dereferenced) from the association (ie: from a collection). I hope this information will help you. You just need to choose what you really need.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.