rename cascade type from DELETE to REMOVE (aligning with JPA terminology)

Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
Gavin King 2024-06-05 12:33:57 +02:00
parent a6ef6d1b55
commit c1433ffdf0
4 changed files with 16 additions and 8 deletions

View File

@ -180,7 +180,7 @@ public final class CascadeStyles {
public static final CascadeStyle DELETE = new BaseCascadeStyle() { public static final CascadeStyle DELETE = new BaseCascadeStyle() {
@Override @Override
public boolean doCascade(CascadingAction action) { public boolean doCascade(CascadingAction action) {
return action == CascadingActions.DELETE return action == CascadingActions.REMOVE
|| action == CascadingActions.CHECK_ON_FLUSH; || action == CascadingActions.CHECK_ON_FLUSH;
} }
@ -196,7 +196,7 @@ public final class CascadeStyles {
public static final CascadeStyle DELETE_ORPHAN = new BaseCascadeStyle() { public static final CascadeStyle DELETE_ORPHAN = new BaseCascadeStyle() {
@Override @Override
public boolean doCascade(CascadingAction action) { public boolean doCascade(CascadingAction action) {
return action == CascadingActions.DELETE return action == CascadingActions.REMOVE
|| action == CascadingActions.SAVE_UPDATE || action == CascadingActions.SAVE_UPDATE
|| action == CascadingActions.PERSIST_ON_FLUSH || action == CascadingActions.PERSIST_ON_FLUSH
|| action == CascadingActions.CHECK_ON_FLUSH; || action == CascadingActions.CHECK_ON_FLUSH;
@ -204,7 +204,7 @@ public final class CascadeStyles {
@Override @Override
public boolean reallyDoCascade(CascadingAction action) { public boolean reallyDoCascade(CascadingAction action) {
return action == CascadingActions.DELETE return action == CascadingActions.REMOVE
|| action == CascadingActions.CHECK_ON_FLUSH; || action == CascadingActions.CHECK_ON_FLUSH;
} }

View File

@ -44,9 +44,9 @@ public class CascadingActions {
} }
/** /**
* @see org.hibernate.Session#delete(Object) * @see org.hibernate.Session#remove(Object)
*/ */
public static final CascadingAction<DeleteContext> DELETE = new BaseCascadingAction<>() { public static final CascadingAction<DeleteContext> REMOVE = new BaseCascadingAction<>() {
@Override @Override
public void cascade( public void cascade(
EventSource session, EventSource session,
@ -79,6 +79,14 @@ public class CascadingActions {
} }
}; };
/**
* @see org.hibernate.Session#delete(Object)
*
* @deprecated Use {@link #REMOVE}
*/
@Deprecated(since = "6.6")
public static final CascadingAction<DeleteContext> DELETE = REMOVE;
/** /**
* @see org.hibernate.Session#lock(Object, LockMode) * @see org.hibernate.Session#lock(Object, LockMode)
*/ */

View File

@ -507,7 +507,7 @@ public class DefaultDeleteEventListener implements DeleteEventListener, Callback
try { try {
// cascade-delete to collections BEFORE the collection owner is deleted // cascade-delete to collections BEFORE the collection owner is deleted
Cascade.cascade( Cascade.cascade(
CascadingActions.DELETE, CascadingActions.REMOVE,
CascadePoint.AFTER_INSERT_BEFORE_DELETE, CascadePoint.AFTER_INSERT_BEFORE_DELETE,
session, session,
persister, persister,
@ -534,7 +534,7 @@ public class DefaultDeleteEventListener implements DeleteEventListener, Callback
try { try {
// cascade-delete to many-to-one AFTER the parent was deleted // cascade-delete to many-to-one AFTER the parent was deleted
Cascade.cascade( Cascade.cascade(
CascadingActions.DELETE, CascadingActions.REMOVE,
CascadePoint.BEFORE_INSERT_AFTER_DELETE, CascadePoint.BEFORE_INSERT_AFTER_DELETE,
session, session,
persister, persister,

View File

@ -363,7 +363,7 @@ public class EntityMetamodel implements Serializable {
if ( cascadeStyles[i] != CascadeStyles.NONE ) { if ( cascadeStyles[i] != CascadeStyles.NONE ) {
foundCascade = true; foundCascade = true;
} }
if ( cascadeStyles[i].doCascade(CascadingActions.DELETE) ) { if ( cascadeStyles[i].doCascade(CascadingActions.REMOVE) ) {
foundCascadeDelete = true; foundCascadeDelete = true;
} }