休眠:OnDelete VS级联= CascadeType.REMOVE [英] Hibernate: OnDelete vs cascade=CascadeType.REMOVE

查看:286
本文介绍了休眠:OnDelete VS级联= CascadeType.REMOVE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是 @OnDelete(动作= OnDeleteAction.CASCADE) =级联CascadeType.REMOVE <之间的差异/ p>

我读到这里:<一href=\"http://stackoverflow.com/questions/6393866/is-there-an-equivalent-annotation-for-ondelete-in-jpa2\">Is那里JPA2 为OnDelete等效注释
@OnDelete(动作= OnDeleteAction.CASCADE)级联将由DB进行处理,同时与 =级联CascadeType.REMOVE 级联将由ORM(休眠)进行处理。


  1. 你能不能解释一下什么是处理之间由Hibernate VS处理由DB区别? 它是如何做,由DB?


  2. 此外,我想知道为什么我要关心的区别。我的意思是,我为什么要选择通过另一种态度。


  3. 最后一个问题是,在看的 OnDelete的javadoc 我想知道为什么它没有提到是什么呢,为什么我应该使用它(顺便说一句在哪里继承路径?)。那么,在这些点记录?



解决方案

1,有些数据库支持级联选项和一些数据库没有:如果数据库支持级联,则Hibernate会相应创建模式,让数据库处理级联

2,如果数据库处理级联使用它,其他的副休眠要查询的数据库,这是失去了一个表现。

3,不知道

What is the difference between @OnDelete(action=OnDeleteAction.CASCADE) and cascade=CascadeType.REMOVE

I read here: Is there an equivalent annotation for OnDelete in JPA2 that with @OnDelete(action=OnDeleteAction.CASCADE) the cascade will be handled by the DB, while with cascade=CascadeType.REMOVE the cascade will be handled by the ORM (Hibernate).

  1. Could you explain what is the difference between handling by Hibernate vs handling by the DB? How is it done "by the DB"?

  2. Also, I would like to know why should I care about the difference. I mean, why should I choose one attitude over the other.

  3. Last question is, looking at the OnDelete javadoc I was wondering why it says nothing about what is does and why I should use it (BTW where is the inheritance path?). So where are these points documented?

解决方案

1-Some database support cascade option and some databases do not :If the database support cascade then hibernate will create schema accordingly and let database to handle cascading.

2-If database handle cascade use it ,other vice hibernate have to query database and this is a performance lost.

3-No idea

这篇关于休眠:OnDelete VS级联= CascadeType.REMOVE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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