Hibernate 中的级联是什么? [英] What is cascading in Hibernate?

查看:15
本文介绍了Hibernate 中的级联是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hibernate 中的级联是什么?我在 map 标签中看到了一个 cascade 属性.这是什么意思?

What is cascading in Hibernate ? There is a cascade attribute I have seen in the map tag. What is it meant for?

比如cascade = all 是什么意思?还有其他我喜欢的属性
cascade="none|save-update|delete|all-delete-orphan|delete-orphan".

Like what does cascade = all mean? There are other attributes I read like
cascade="none|save-update|delete|all-delete-orphan|delete-orphan".

推荐答案

级联是关于持久性操作,涉及一个对象通过关联传播到其他对象.级联可以应用于各种 Hibernate 操作,并且它通常是可传递的.定义关联的注解的cascade=..."属性表示该关联应该级联哪些操作.

Cascading is about persistence actions involving one object propagating to other objects via an association. Cascading can apply to a variety of Hibernate actions, and it is typically transitive. The "cascade=..." attribute of the annotation that defines the association says what actions should cascade for that association.

Cascade = "all" 表示应用所有主要级联类型.从 Hibernate 5.3 开始,这些类型是:

Cascade = "all" means to apply all primary cascade types. As of Hibernate 5.3, these types are:

  • 删除"/移除",
  • 分离"/驱逐",
  • 合并",
  • 锁",
  • 坚持",
  • 刷新",
  • 复制",
  • save_update"/更新"

(其中一些级联类型名称已过时和/或已弃用.)

(Some of those cascade type names are old and/or deprecated.)

还有另外三种复合类型:

There are three more compound types:

  • all_delete_orphan" - 与all"的意思相同,外加允许删除被级联孤立的实体.
  • delete_orphan" - 表示删除"加上孤立删除.
  • none" - 表示没有级联.

这篇关于Hibernate 中的级联是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆