Is there a difference between :
是否有区别:
- @Cascade(org.hibernate.annotations.CascadeType.REMOVE) and
- @Cascade(org.hibernate.annotations.CascadeType.REMOVE)和
- @Cascade(org.hibernate.annotations.CascadeType.DELETE) ?
- @Cascade(org.hibernate.annotations.CascadeType.DELETE)?
1 个解决方案
#1
22
There is no difference; they're synonyms.
没有区别;他们是同义词。
Documentation is rather silent on this but if you look at AnnotationBinder.getCascadeStrategy()
source, both are being translated to Hibernate's "delete" cascade type.
文档对此非常安静,但如果你看一下AnnotationBinder.getCascadeStrategy()源代码,两者都被翻译成Hibernate的“删除”级联类型。
The reason that both exist (and I'm guessing here) is because Hibernate core has always used "DELETE" as cascade type, but JPA's CascadeType specifies "REMOVE" as a constant. Hibernate Annotations' CascadeType, being part of Hibernate's JPA extension thus has both for completeness / consistency.
两者都存在(我猜这里)的原因是因为Hibernate核心总是使用“DELETE”作为级联类型,但JPA的CascadeType将“REMOVE”指定为常量。 Hibernate Annotations的CascadeType是Hibernate的JPA扩展的一部分,因此具有完整性/一致性。
#1
22
There is no difference; they're synonyms.
没有区别;他们是同义词。
Documentation is rather silent on this but if you look at AnnotationBinder.getCascadeStrategy()
source, both are being translated to Hibernate's "delete" cascade type.
文档对此非常安静,但如果你看一下AnnotationBinder.getCascadeStrategy()源代码,两者都被翻译成Hibernate的“删除”级联类型。
The reason that both exist (and I'm guessing here) is because Hibernate core has always used "DELETE" as cascade type, but JPA's CascadeType specifies "REMOVE" as a constant. Hibernate Annotations' CascadeType, being part of Hibernate's JPA extension thus has both for completeness / consistency.
两者都存在(我猜这里)的原因是因为Hibernate核心总是使用“DELETE”作为级联类型,但JPA的CascadeType将“REMOVE”指定为常量。 Hibernate Annotations的CascadeType是Hibernate的JPA扩展的一部分,因此具有完整性/一致性。