diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/mutation/internal/MutationExecutorPostInsert.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/mutation/internal/MutationExecutorPostInsert.java index 87b1310fed..c30349d03b 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/mutation/internal/MutationExecutorPostInsert.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/mutation/internal/MutationExecutorPostInsert.java @@ -71,7 +71,7 @@ public class MutationExecutorPostInsert implements MutationExecutor, JdbcValueBi ); this.mutationOperationGroup = mutationOperationGroup; - final PreparableMutationOperation identityInsertOperation = mutationOperationGroup.getOperation( mutationTarget.getIdentifierTableName() ); + final PreparableMutationOperation identityInsertOperation = (PreparableMutationOperation) mutationOperationGroup.getOperation( mutationTarget.getIdentifierTableName() ); this.identityInsertStatementDetails = ModelMutationHelper.identityPreparation( identityInsertOperation, session @@ -79,9 +79,8 @@ public class MutationExecutorPostInsert implements MutationExecutor, JdbcValueBi List secondaryTableMutations = null; - final List operations = mutationOperationGroup.getOperations(); - for ( int i = 0; i < operations.size(); i++ ) { - final MutationOperation operation = operations.get( i ); + for ( int i = 0; i < mutationOperationGroup.getNumberOfOperations(); i++ ) { + final MutationOperation operation = mutationOperationGroup.getOperation( i ); if ( operation.getTableDetails().isIdentifierTable() ) { // the identifier table is handled via `identityInsertStatementDetails` diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/mutation/internal/MutationExecutorPostInsertSingleTable.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/mutation/internal/MutationExecutorPostInsertSingleTable.java index d35717bc33..b85a46bc7a 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/mutation/internal/MutationExecutorPostInsertSingleTable.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/mutation/internal/MutationExecutorPostInsertSingleTable.java @@ -59,7 +59,7 @@ public class MutationExecutorPostInsertSingleTable implements MutationExecutor, assert mutationOperationGroup.getNumberOfOperations() == 1; - this.operation = mutationOperationGroup.getOperation( mutationTarget.getIdentifierTableName() ); + this.operation = (PreparableMutationOperation) mutationOperationGroup.getOperation( mutationTarget.getIdentifierTableName() ); this.identityInsertStatementDetails = identityPreparation( operation, session ); this.valueBindings = new JdbcValueBindingsImpl( diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/mutation/internal/MutationExecutorStandard.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/mutation/internal/MutationExecutorStandard.java index cc1ed5ed96..85abe0bef7 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/mutation/internal/MutationExecutorStandard.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/mutation/internal/MutationExecutorStandard.java @@ -11,7 +11,6 @@ import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.function.Supplier; import org.hibernate.engine.jdbc.batch.spi.Batch; import org.hibernate.engine.jdbc.batch.spi.BatchKey; @@ -23,7 +22,6 @@ import org.hibernate.engine.jdbc.mutation.group.PreparedStatementDetails; import org.hibernate.engine.jdbc.mutation.group.PreparedStatementGroup; import org.hibernate.engine.jdbc.mutation.spi.BatchKeyAccess; import org.hibernate.engine.spi.SharedSessionContractImplementor; -import org.hibernate.internal.util.collections.CollectionHelper; import org.hibernate.sql.model.MutationOperation; import org.hibernate.sql.model.MutationOperationGroup; import org.hibernate.sql.model.PreparableMutationOperation; @@ -79,12 +77,10 @@ public class MutationExecutorStandard extends AbstractMutationExecutor implement List nonBatchedJdbcMutations = null; List selfExecutingMutations = null; - final List operations = mutationOperationGroup.getOperations(); - boolean hasAnyNonBatchedJdbcOperations = false; - for ( int i = operations.size() - 1; i >= 0; i-- ) { - final MutationOperation operation = operations.get( i ); + for ( int i = mutationOperationGroup.getNumberOfOperations() - 1; i >= 0; i-- ) { + final MutationOperation operation = mutationOperationGroup.getOperation( i ); if ( operation instanceof SelfExecutingUpdateOperation ) { final SelfExecutingUpdateOperation selfExecutingMutation = (SelfExecutingUpdateOperation) operation; if ( selfExecutingMutations == null ) { diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java index b321a04888..c592bef97f 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java @@ -255,6 +255,7 @@ import org.hibernate.sql.ast.tree.select.SelectClause; import org.hibernate.sql.ast.tree.select.SelectStatement; import org.hibernate.sql.exec.spi.JdbcOperation; import org.hibernate.sql.exec.spi.JdbcParametersList; +import org.hibernate.sql.model.MutationOperation; import org.hibernate.sql.model.MutationOperationGroup; import org.hibernate.sql.model.ast.builder.MutationGroupBuilder; import org.hibernate.sql.results.graph.DomainResult; @@ -2919,25 +2920,41 @@ public abstract class AbstractEntityPersister LOG.debugf( " Version select: %s", sqlVersionSelectString ); } - if ( insertCoordinator.getStaticInsertGroup() != null ) { - insertCoordinator.getStaticInsertGroup().forEachOperation( (tablePosition, mutation) -> { - if ( mutation instanceof JdbcOperation ) { - LOG.debugf( " Insert (%s): %s", tablePosition, ( (JdbcOperation) mutation ).getSqlString() ); + { + final MutationOperationGroup staticInsertGroup = insertCoordinator.getStaticInsertGroup(); + if ( staticInsertGroup != null ) { + for ( int i = 0; i < staticInsertGroup.getNumberOfOperations(); i++ ) { + final MutationOperation mutation = staticInsertGroup.getOperation( i ); + if ( mutation instanceof JdbcOperation ) { + LOG.debugf( " Insert (%s): %s", i, ( (JdbcOperation) mutation ).getSqlString() ); + } } - } ); + } } - updateCoordinator.getStaticUpdateGroup().forEachOperation( (tablePosition, mutation) -> { - if ( mutation instanceof JdbcOperation ) { - LOG.debugf( " Update (%s): %s", tablePosition, ( (JdbcOperation) mutation ).getSqlString() ); + { + final MutationOperationGroup staticUpdateGroup = updateCoordinator.getStaticUpdateGroup(); + if ( staticUpdateGroup != null ) { + for ( int i = 0; i < staticUpdateGroup.getNumberOfOperations(); i++ ) { + final MutationOperation mutation = staticUpdateGroup.getOperation( i ); + if ( mutation instanceof JdbcOperation ) { + LOG.debugf( " Update (%s): %s", i, ( (JdbcOperation) mutation ).getSqlString() ); + } + } } - } ); + } - deleteCoordinator.getStaticDeleteGroup().forEachOperation( (tablePosition, mutation) -> { - if ( mutation instanceof JdbcOperation ) { - LOG.debugf( " Delete (%s): %s", tablePosition, ( (JdbcOperation) mutation ).getSqlString() ); + { + final MutationOperationGroup staticDeleteGroup = deleteCoordinator.getStaticDeleteGroup(); + if ( staticDeleteGroup != null ) { + for ( int i = 0; i < staticDeleteGroup.getNumberOfOperations(); i++ ) { + final MutationOperation mutation = staticDeleteGroup.getOperation( i ); + if ( mutation instanceof JdbcOperation ) { + LOG.debugf( " Delete (%s): %s", i, ( (JdbcOperation) mutation ).getSqlString() ); + } + } } - } ); + } } } @@ -6087,12 +6104,14 @@ public abstract class AbstractEntityPersister } private String[] extractSqlStrings(MutationOperationGroup operationGroup) { - final String[] strings = new String[operationGroup.getNumberOfOperations()]; - operationGroup.forEachOperation( (tableIndex, mutation) -> { - if ( mutation instanceof JdbcOperation ) { - strings[tableIndex] = ( (JdbcOperation) mutation ).getSqlString(); + final int numberOfOperations = operationGroup.getNumberOfOperations(); + final String[] strings = new String[numberOfOperations]; + for ( int i = 0; i < numberOfOperations; i++ ) { + final MutationOperation operation = operationGroup.getOperation( i ); + if ( operation instanceof JdbcOperation ) { + strings[i] = ( (JdbcOperation) operation ).getSqlString(); } - } ); + } return strings; } diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/AbstractMutationCoordinator.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/AbstractMutationCoordinator.java index e25a30a6ef..633e32912e 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/AbstractMutationCoordinator.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/AbstractMutationCoordinator.java @@ -32,6 +32,7 @@ import org.hibernate.sql.model.ast.builder.MutationGroupBuilder; import org.hibernate.sql.model.internal.MutationOperationGroupNone; import org.hibernate.sql.model.internal.MutationOperationGroupSingle; import org.hibernate.sql.model.internal.MutationOperationGroupStandard; +import org.hibernate.sql.model.jdbc.JdbcMutationOperation; import static org.hibernate.internal.util.collections.CollectionHelper.arrayList; @@ -90,7 +91,7 @@ public abstract class AbstractMutationCoordinator { .createMutationOperation( valuesAnalysis, factory() ); return operation == null ? new MutationOperationGroupNone( mutationGroup ) - : new MutationOperationGroupSingle( mutationGroup, operation ); + : new MutationOperationGroupSingle( mutationGroup, (JdbcMutationOperation) operation ); } default: { final List operations = arrayList( numberOfTableMutations ); diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/DeleteCoordinator.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/DeleteCoordinator.java index 79189ab228..95d45e50e1 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/DeleteCoordinator.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/DeleteCoordinator.java @@ -23,6 +23,7 @@ import org.hibernate.metamodel.mapping.EntityRowIdMapping; import org.hibernate.metamodel.mapping.EntityVersionMapping; import org.hibernate.metamodel.mapping.SelectableMapping; import org.hibernate.persister.entity.AbstractEntityPersister; +import org.hibernate.sql.model.MutationOperation; import org.hibernate.sql.model.MutationOperationGroup; import org.hibernate.sql.model.MutationType; import org.hibernate.sql.model.ast.builder.MutationGroupBuilder; @@ -97,12 +98,13 @@ public class DeleteCoordinator extends AbstractMutationCoordinator { final MutationExecutor mutationExecutor = executor( session, operationGroup ); - operationGroup.forEachOperation( (position, mutation) -> { + for ( int i = 0; i < operationGroup.getNumberOfOperations(); i++ ) { + final MutationOperation mutation = operationGroup.getOperation( i ); if ( mutation != null ) { final String tableName = mutation.getTableDetails().getTableName(); mutationExecutor.getPreparedStatementDetails( tableName ); } - } ); + } applyLocking( null, loadedState, mutationExecutor, session ); @@ -213,10 +215,12 @@ public class DeleteCoordinator extends AbstractMutationCoordinator { MutationExecutor mutationExecutor, MutationOperationGroup operationGroup, SharedSessionContractImplementor session) { + final JdbcValueBindings jdbcValueBindings = mutationExecutor.getJdbcValueBindings(); final EntityRowIdMapping rowIdMapping = entityPersister().getRowIdMapping(); - operationGroup.forEachOperation( (position, jdbcMutation) -> { + for ( int position = 0; position < operationGroup.getNumberOfOperations(); position++ ) { + final MutationOperation jdbcMutation = operationGroup.getOperation( position ); final EntityTableMapping tableDetails = (EntityTableMapping) jdbcMutation.getTableDetails(); breakDownIdJdbcValues( id, rowId, session, jdbcValueBindings, rowIdMapping, tableDetails ); final PreparedStatementDetails statementDetails = mutationExecutor.getPreparedStatementDetails( tableDetails.getTableName() ); @@ -225,7 +229,7 @@ public class DeleteCoordinator extends AbstractMutationCoordinator { //noinspection resource statementDetails.resolveStatement(); } - } ); + } } private static void breakDownIdJdbcValues( @@ -279,11 +283,12 @@ public class DeleteCoordinator extends AbstractMutationCoordinator { final MutationExecutor mutationExecutor = executor( session, operationGroupToUse ); - staticOperationGroup.forEachOperation( (position, mutation) -> { + for ( int position = 0; position < staticOperationGroup.getNumberOfOperations(); position++ ) { + final MutationOperation mutation = staticOperationGroup.getOperation( position ); if ( mutation != null ) { mutationExecutor.getPreparedStatementDetails( mutation.getTableDetails().getTableName() ); } - } ); + } if ( applyVersion ) { applyLocking( version, null, mutationExecutor, session ); diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/InsertCoordinator.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/InsertCoordinator.java index baa97dd5c0..68be0e5304 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/InsertCoordinator.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/InsertCoordinator.java @@ -28,6 +28,7 @@ import org.hibernate.metamodel.mapping.AttributeMappingsList; import org.hibernate.metamodel.mapping.BasicEntityIdentifierMapping; import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.persister.entity.AbstractEntityPersister; +import org.hibernate.sql.model.MutationOperation; import org.hibernate.sql.model.MutationOperationGroup; import org.hibernate.sql.model.MutationType; import org.hibernate.sql.model.TableMapping; @@ -196,22 +197,25 @@ public class InsertCoordinator extends AbstractMutationCoordinator { TableInclusionChecker tableInclusionChecker, SharedSessionContractImplementor session) { final JdbcValueBindings jdbcValueBindings = mutationExecutor.getJdbcValueBindings(); + final AttributeMappingsList attributeMappings = entityPersister().getAttributeMappings(); - mutationGroup.forEachOperation( (position, operation) -> { + for ( int position = 0; position < mutationGroup.getNumberOfOperations(); position++ ) { + final MutationOperation operation = mutationGroup.getOperation( position ); final EntityTableMapping tableDetails = (EntityTableMapping) operation.getTableDetails(); if ( tableInclusionChecker.include( tableDetails ) ) { final int[] attributeIndexes = tableDetails.getAttributeIndexes(); for ( int i = 0; i < attributeIndexes.length; i++ ) { final int attributeIndex = attributeIndexes[ i ]; if ( propertyInclusions[attributeIndex] ) { - final AttributeMapping mapping = entityPersister().getAttributeMappings().get( attributeIndex ); + final AttributeMapping mapping = attributeMappings.get( attributeIndex ); decomposeAttribute( values[attributeIndex], session, jdbcValueBindings, mapping ); } } } - } ); + } - mutationGroup.forEachOperation( (position, jdbcOperation) -> { + for ( int position = 0; position < mutationGroup.getNumberOfOperations(); position++ ) { + final MutationOperation jdbcOperation = mutationGroup.getOperation( position ); if ( id == null ) { assert entityPersister().getIdentityInsertDelegate() != null; } @@ -219,7 +223,7 @@ public class InsertCoordinator extends AbstractMutationCoordinator { final EntityTableMapping tableDetails = (EntityTableMapping) jdbcOperation.getTableDetails(); breakDownJdbcValue( id, session, jdbcValueBindings, tableDetails ); } - } ); + } } protected void breakDownJdbcValue( diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/UpdateCoordinatorStandard.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/UpdateCoordinatorStandard.java index da2c813cf2..d5493d7ef4 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/UpdateCoordinatorStandard.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/UpdateCoordinatorStandard.java @@ -775,7 +775,8 @@ public class UpdateCoordinatorStandard extends AbstractMutationCoordinator imple final JdbcValueBindings jdbcValueBindings = mutationExecutor.getJdbcValueBindings(); // apply values - jdbcOperationGroup.forEachOperation( (position, operation) -> { + for ( int position = 0; position < jdbcOperationGroup.getNumberOfOperations(); position++ ) { + final MutationOperation operation = jdbcOperationGroup.getOperation( position ); final EntityTableMapping tableMapping = (EntityTableMapping) operation.getTableDetails(); if ( valuesAnalysis.tablesNeedingUpdate.contains( tableMapping ) ) { final int[] attributeIndexes = tableMapping.getAttributeIndexes(); @@ -791,13 +792,14 @@ public class UpdateCoordinatorStandard extends AbstractMutationCoordinator imple ); } } - } ); + } // apply keys - jdbcOperationGroup.forEachOperation( (position, operation) -> { + for ( int position = 0; position < jdbcOperationGroup.getNumberOfOperations(); position++ ) { + final MutationOperation operation = jdbcOperationGroup.getOperation( position ); final EntityTableMapping tableMapping = (EntityTableMapping) operation.getTableDetails(); breakDownKeyJdbcValues( id, rowId, session, jdbcValueBindings, tableMapping ); - } ); + } } private void decomposeAttributeForUpdate( diff --git a/hibernate-core/src/main/java/org/hibernate/sql/model/MutationOperationGroup.java b/hibernate-core/src/main/java/org/hibernate/sql/model/MutationOperationGroup.java index 62b85bbec2..bbef194d94 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/model/MutationOperationGroup.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/model/MutationOperationGroup.java @@ -17,6 +17,7 @@ import java.util.function.BiFunction; * @author Steve Ebersole */ public interface MutationOperationGroup { + /** * The type of mutation (at the model-level) represented by this group. */ @@ -37,22 +38,41 @@ public interface MutationOperationGroup { * * Throws an exception if there are more than one. */ - O getSingleOperation(); + MutationOperation getSingleOperation(); - List getOperations(); + /** + * Gets a specific MutationOperation from the group + * @param idx the index, starting from zero. + * @return + */ + MutationOperation getOperation(int idx); /** * Get the operation for a specific table. */ - O getOperation(String tableName); + MutationOperation getOperation(String tableName); + + /** + * @deprecated Will be removed - use a combination of {@link #getNumberOfOperations()} and {@link #getOperation(int)} + * to iterate the list of operations. + */ + @Deprecated(forRemoval = true) + List getOperations(); /** * Visit each operation + * @deprecated Will be removed - use a combination of {@link #getNumberOfOperations()} and {@link #getOperation(int)} + * to iterate the list of operations. */ - void forEachOperation(BiConsumer action); + @Deprecated(forRemoval = true) + void forEachOperation(BiConsumer action); /** * Test whether any operations match the condition + * @deprecated Will be removed - use a combination of {@link #getNumberOfOperations()} and {@link #getOperation(int)} + * to iterate the list of operations. */ - boolean hasMatching(BiFunction matcher); + @Deprecated(forRemoval = true) + boolean hasMatching(BiFunction matcher); + } diff --git a/hibernate-core/src/main/java/org/hibernate/sql/model/internal/MutationOperationGroupNone.java b/hibernate-core/src/main/java/org/hibernate/sql/model/internal/MutationOperationGroupNone.java index 9c5df52f5f..520c5c87e0 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/model/internal/MutationOperationGroupNone.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/model/internal/MutationOperationGroupNone.java @@ -35,26 +35,32 @@ public class MutationOperationGroupNone extends AbstractMutationOperationGroup { } @Override - public O getSingleOperation() { + public MutationOperation getSingleOperation() { return null; } @Override - public List getOperations() { + public MutationOperation getOperation(int idx) { + throw new IndexOutOfBoundsException( idx ); + } + + @Override + public List getOperations() { return Collections.emptyList(); } @Override - public O getOperation(String tableName) { + public MutationOperation getOperation(String tableName) { return null; } @Override - public void forEachOperation(BiConsumer action) { + public void forEachOperation(BiConsumer action) { } @Override - public boolean hasMatching(BiFunction matcher) { + public boolean hasMatching(BiFunction matcher) { return false; } + } diff --git a/hibernate-core/src/main/java/org/hibernate/sql/model/internal/MutationOperationGroupSingle.java b/hibernate-core/src/main/java/org/hibernate/sql/model/internal/MutationOperationGroupSingle.java index e27bfe775e..04a0f828ce 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/model/internal/MutationOperationGroupSingle.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/model/internal/MutationOperationGroupSingle.java @@ -15,6 +15,7 @@ import org.hibernate.sql.model.MutationOperation; import org.hibernate.sql.model.MutationTarget; import org.hibernate.sql.model.MutationType; import org.hibernate.sql.model.ast.MutationGroup; +import org.hibernate.sql.model.jdbc.JdbcMutationOperation; import static org.hibernate.sql.model.ModelMutationLogging.MODEL_MUTATION_LOGGER; @@ -22,14 +23,15 @@ import static org.hibernate.sql.model.ModelMutationLogging.MODEL_MUTATION_LOGGER * @author Steve Ebersole */ public class MutationOperationGroupSingle extends AbstractMutationOperationGroup { - private final MutationOperation operation; - public MutationOperationGroupSingle(MutationType mutationType, MutationTarget mutationTarget, MutationOperation operation) { + private final JdbcMutationOperation operation; + + public MutationOperationGroupSingle(MutationType mutationType, MutationTarget mutationTarget, JdbcMutationOperation operation) { super( mutationType, mutationTarget ); this.operation = operation; } - public MutationOperationGroupSingle(MutationGroup mutationGroup, MutationOperation operation) { + public MutationOperationGroupSingle(MutationGroup mutationGroup, JdbcMutationOperation operation) { this( mutationGroup.getMutationType(), mutationGroup.getMutationTarget(), operation ); } @@ -39,19 +41,23 @@ public class MutationOperationGroupSingle extends AbstractMutationOperationGroup } @Override - public O getSingleOperation() { - //noinspection unchecked - return (O) operation; + public JdbcMutationOperation getSingleOperation() { + return operation; } @Override - public List getOperations() { - //noinspection unchecked - return Collections.singletonList( (O) operation ); + public MutationOperation getOperation(int idx) { + if ( idx != 0 ) throw new IndexOutOfBoundsException( idx ); + return operation; } @Override - public O getOperation(String tableName) { + public List getOperations() { + return Collections.singletonList( operation ); + } + + @Override + public MutationOperation getOperation(String tableName) { if ( !tableName.equals( operation.getTableDetails().getTableName() ) ) { MODEL_MUTATION_LOGGER.debugf( "Unexpected table name mismatch : `%s` - `%s`", @@ -60,19 +66,17 @@ public class MutationOperationGroupSingle extends AbstractMutationOperationGroup ); } - //noinspection unchecked - return (O) operation; + return operation; } @Override - public void forEachOperation(BiConsumer action) { - //noinspection unchecked - action.accept( 0, (O) operation ); + public void forEachOperation(BiConsumer action) { + action.accept( 0, operation ); } @Override - public boolean hasMatching(BiFunction matcher) { - //noinspection unchecked - return matcher.apply( 0, (O) operation ); + public boolean hasMatching(BiFunction matcher) { + return matcher.apply( 0, operation ); } + } diff --git a/hibernate-core/src/main/java/org/hibernate/sql/model/internal/MutationOperationGroupStandard.java b/hibernate-core/src/main/java/org/hibernate/sql/model/internal/MutationOperationGroupStandard.java index 29cb70f1b6..fc0b4273b4 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/model/internal/MutationOperationGroupStandard.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/model/internal/MutationOperationGroupStandard.java @@ -32,10 +32,9 @@ public class MutationOperationGroupStandard extends AbstractMutationOperationGro } @Override - public O getSingleOperation() { + public MutationOperation getSingleOperation() { if ( operations.size() == 1 ) { - //noinspection unchecked - return (O) operations.get( 0 ); + return operations.get( 0 ); } throw new IllegalStateException( String.format( @@ -47,38 +46,38 @@ public class MutationOperationGroupStandard extends AbstractMutationOperationGro ); } - @SuppressWarnings("unchecked") @Override - public List getOperations() { - //noinspection rawtypes - return (List) operations; + public MutationOperation getOperation(int idx) { + return operations.get( idx ); } - @SuppressWarnings("unchecked") @Override - public O getOperation(String tableName) { + public List getOperations() { + return operations; + } + + @Override + public MutationOperation getOperation(String tableName) { for ( int i = 0; i < operations.size(); i++ ) { final MutationOperation operation = operations.get( i ); if ( operation.getTableDetails().getTableName().equals( tableName ) ) { - return (O) operation; + return operation; } } return null; } - @SuppressWarnings("unchecked") @Override - public void forEachOperation(BiConsumer action) { + public void forEachOperation(BiConsumer action) { for ( int i = 0; i < operations.size(); i++ ) { - action.accept( i, (O) operations.get( i ) ); + action.accept( i, operations.get( i ) ); } } - @SuppressWarnings("unchecked") @Override - public boolean hasMatching(BiFunction matcher) { + public boolean hasMatching(BiFunction matcher) { for ( int i = 0; i < operations.size(); i++ ) { - if ( matcher.apply( i, (O) operations.get( i ) ) ) { + if ( matcher.apply( i, operations.get( i ) ) ) { return true; } }