diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java index 8132e017cd..6131384d76 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java @@ -17,6 +17,7 @@ import java.util.Properties; import org.hibernate.AssertionFailure; import org.hibernate.FetchMode; import org.hibernate.annotations.CascadeType; +import org.hibernate.annotations.OnDeleteAction; import org.hibernate.annotations.SourceType; import org.hibernate.boot.MappingException; import org.hibernate.boot.jaxb.Origin; @@ -562,7 +563,7 @@ public class ModelBinder { keyBinding.makeNationalized(); } entityDescriptor.setKey( keyBinding ); - keyBinding.setCascadeDeleteEnabled( entitySource.isCascadeDeleteEnabled() ); + keyBinding.setOnDeleteAction( getOnDeleteAction( entitySource.isCascadeDeleteEnabled() ) ); relationalObjectBinder.bindColumns( mappingDocument, entitySource.getPrimaryKeyColumnSources(), @@ -593,7 +594,6 @@ public class ModelBinder { bindJoinedSubclassEntities( entitySource, entityDescriptor ); } - private void bindUnionSubclassEntities( EntitySource entitySource, PersistentClass superEntityDescriptor) { @@ -1622,7 +1622,7 @@ public class ModelBinder { } secondaryTableJoin.setKey( keyBinding ); - keyBinding.setCascadeDeleteEnabled( secondaryTableSource.isCascadeDeleteEnabled() ); + keyBinding.setOnDeleteAction( getOnDeleteAction( secondaryTableSource.isCascadeDeleteEnabled() ) ); // NOTE : no Type info to bind... @@ -1972,7 +1972,7 @@ public class ModelBinder { setForeignKeyName( oneToOneBinding, oneToOneSource.getExplicitForeignKeyName() ); } - oneToOneBinding.setCascadeDeleteEnabled( oneToOneSource.isCascadeDeleteEnabled() ); + oneToOneBinding.setOnDeleteAction( getOnDeleteAction( oneToOneSource.isCascadeDeleteEnabled() ) ); } private Property createManyToOneAttribute( @@ -2121,7 +2121,7 @@ public class ModelBinder { } } - manyToOneBinding.setCascadeDeleteEnabled( manyToOneSource.isCascadeDeleteEnabled() ); + manyToOneBinding.setOnDeleteAction( getOnDeleteAction( manyToOneSource.isCascadeDeleteEnabled() ) ); } private static void setForeignKeyName(SimpleValue manyToOneBinding, String foreignKeyName) { @@ -3203,8 +3203,8 @@ public class ModelBinder { keyVal ); setForeignKeyName( key, keySource.getExplicitForeignKeyName() ); - key.setCascadeDeleteEnabled( getPluralAttributeSource().getKeySource().isCascadeDeleteEnabled() ); -// + key.setOnDeleteAction( getOnDeleteAction( getPluralAttributeSource().getKeySource().isCascadeDeleteEnabled() ) ); + // final ImplicitJoinColumnNameSource.Nature implicitNamingNature; // if ( getPluralAttributeSource().getElementSource() instanceof PluralAttributeElementSourceManyToMany // || getPluralAttributeSource().getElementSource() instanceof PluralAttributeElementSourceOneToMany ) { @@ -4069,4 +4069,8 @@ public class ModelBinder { } return builder.toString(); } + + private static OnDeleteAction getOnDeleteAction(boolean entitySource) { + return entitySource ? OnDeleteAction.CASCADE : OnDeleteAction.NO_ACTION; + } } diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java b/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java index ae380b1943..b75bb23898 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java @@ -35,8 +35,6 @@ import org.hibernate.boot.spi.MetadataImplementor; import org.hibernate.dialect.Dialect; import org.hibernate.generator.Generator; import org.hibernate.generator.GeneratorCreationContext; -import org.hibernate.internal.CoreLogging; -import org.hibernate.internal.CoreMessageLogger; import org.hibernate.models.spi.MemberDetails; import org.hibernate.models.spi.TypeDetails; import org.hibernate.resource.beans.spi.ManagedBeanRegistry; @@ -72,7 +70,6 @@ import static org.hibernate.internal.util.collections.ArrayHelper.toBooleanArray * @author Yanming Zhou */ public abstract class SimpleValue implements KeyValue { - private static final CoreMessageLogger log = CoreLogging.messageLogger( SimpleValue.class ); @Deprecated(since = "7.0", forRemoval = true) public static final String DEFAULT_ID_GEN_STRATEGY = ASSIGNED_GENERATOR_NAME; @@ -171,24 +168,11 @@ public abstract class SimpleValue implements KeyValue { return onDeleteAction; } - /** - * @deprecated use {@link #getOnDeleteAction()} - */ - @Deprecated(since = "6.2") @Override public boolean isCascadeDeleteEnabled() { return onDeleteAction == OnDeleteAction.CASCADE; } - /** - * @deprecated use {@link #setOnDeleteAction(OnDeleteAction)} - */ - @Deprecated(since = "6.2") - public void setCascadeDeleteEnabled(boolean cascadeDeleteEnabled) { - this.onDeleteAction = cascadeDeleteEnabled ? OnDeleteAction.CASCADE : OnDeleteAction.NO_ACTION; - } - - public void addColumn(Column column) { addColumn( column, true, true ); }