What is the difference between REMOVE and DELETE?

marhatta picture marhatta · Sep 25, 2009 · Viewed 11.9k times · Source

Is there a difference between :

  • @Cascade(org.hibernate.annotations.CascadeType.REMOVE) and
  • @Cascade(org.hibernate.annotations.CascadeType.DELETE) ?

Answer

ChssPly76 picture ChssPly76 · Sep 25, 2009

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.

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.