@CascadeOnDelete和CascadeType.REMOVE注释之间有什么区别?

时间:2023-01-24 00:07:00

At first I've expected that with CascadeType.REMOVE I'll be able to delete foreign keys in my table , but I sill got an exception. But with @CascadeOnDelete it's ok .What's the difference between the two annotations?

起初我已经预料到使用CascadeType.REMOVE我将能够删除表中的外键,但我有一个例外。但是对于@CascadeOnDelete,没关系。两个注释之间有什么区别?

EDIT: I've saw the DataNucleus' comment.Cascade on delete comes from org.eclipse.persistence.annotations.CascadeOnDelete .Which raises the question how good idea is to be used.

编辑:我看过DataNucleus的评论。删除上的过滤来自org.eclipse.persistence.annotations.CascadeOnDelete .Which提出了如何使用好主意的问题。

1 个解决方案

#1


6  

When you use CascadeType.Remove at the time the cascading will be handled by the ORM tool but when you want the cascading to be handled by the database you can use @CascadeOnDelete.but when you are using @CascadeOnDelete , make sure the Database you are using should support cascading.

当您使用CascadeType.Remove时,级联将由ORM工具处理,但是当您希望数据库处理级联时,您可以使用@ CascadeOnDelete。但是当您使用@CascadeOnDelete时,请确保数据库是使用应该支持级联。

#1


6  

When you use CascadeType.Remove at the time the cascading will be handled by the ORM tool but when you want the cascading to be handled by the database you can use @CascadeOnDelete.but when you are using @CascadeOnDelete , make sure the Database you are using should support cascading.

当您使用CascadeType.Remove时,级联将由ORM工具处理,但是当您希望数据库处理级联时,您可以使用@ CascadeOnDelete。但是当您使用@CascadeOnDelete时,请确保数据库是使用应该支持级联。