diff --git a/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/CollectionLoaderSubSelectFetch.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/CollectionLoaderSubSelectFetch.java index 61d8423912..e86a61a894 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/CollectionLoaderSubSelectFetch.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/CollectionLoaderSubSelectFetch.java @@ -6,7 +6,6 @@ */ package org.hibernate.loader.ast.internal; -import java.util.ArrayList; import java.util.Iterator; import java.util.List; diff --git a/hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeNonSelectQueryPlanImpl.java b/hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeNonSelectQueryPlanImpl.java index 149984203e..0ef7d7692b 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeNonSelectQueryPlanImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeNonSelectQueryPlanImpl.java @@ -109,7 +109,7 @@ public class NativeNonSelectQueryPlanImpl implements NonSelectQueryPlan { .getStatementPreparer() .prepareStatement( sql ), (integer, preparedStatement) -> {}, - new SqmJdbcExecutionContextAdapter( executionContext ) + SqmJdbcExecutionContextAdapter.usingLockingAndPaging( executionContext ) ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeSelectQueryPlanImpl.java b/hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeSelectQueryPlanImpl.java index 991e9820d7..1a7aafb1f7 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeSelectQueryPlanImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeSelectQueryPlanImpl.java @@ -127,7 +127,7 @@ public class NativeSelectQueryPlanImpl implements NativeSelectQueryPlan { return executor.list( jdbcSelect, jdbcParameterBindings, - new SqmJdbcExecutionContextAdapter( executionContext, executionContext.getQueryOptions() ), + SqmJdbcExecutionContextAdapter.usingLockingAndPaging( executionContext ), null, ListResultsConsumer.UniqueSemantic.NONE ); @@ -192,7 +192,7 @@ public class NativeSelectQueryPlanImpl implements NativeSelectQueryPlan { jdbcSelect, scrollMode, jdbcParameterBindings, - new SqmJdbcExecutionContextAdapter( executionContext, executionContext.getQueryOptions() ), + SqmJdbcExecutionContextAdapter.usingLockingAndPaging( executionContext ), null ); } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SimpleDeleteQueryPlan.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SimpleDeleteQueryPlan.java index 73d1cb8f0a..72075da5b4 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SimpleDeleteQueryPlan.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SimpleDeleteQueryPlan.java @@ -126,7 +126,7 @@ public class SimpleDeleteQueryPlan implements NonSelectQueryPlan { assert jdbcParamsXref.isEmpty(); } - final SqmJdbcExecutionContextAdapter executionContextAdapter = new SqmJdbcExecutionContextAdapter( executionContext ); + final SqmJdbcExecutionContextAdapter executionContextAdapter = SqmJdbcExecutionContextAdapter.usingLockingAndPaging( executionContext ); SqmMutationStrategyHelper.cleanUpCollectionTables( entityDescriptor, diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SimpleInsertQueryPlan.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SimpleInsertQueryPlan.java index 6c479f28a9..69ffc19a05 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SimpleInsertQueryPlan.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SimpleInsertQueryPlan.java @@ -123,7 +123,7 @@ public class SimpleInsertQueryPlan implements NonSelectQueryPlan { .getStatementPreparer() .prepareStatement( sql ), (integer, preparedStatement) -> {}, - new SqmJdbcExecutionContextAdapter( executionContext ) + SqmJdbcExecutionContextAdapter.omittingLockingAndPaging( executionContext ) ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SimpleUpdateQueryPlan.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SimpleUpdateQueryPlan.java index 8b37c7c54f..20d67c500b 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SimpleUpdateQueryPlan.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SimpleUpdateQueryPlan.java @@ -92,7 +92,7 @@ public class SimpleUpdateQueryPlan implements NonSelectQueryPlan { .getStatementPreparer() .prepareStatement( sql ), (integer, preparedStatement) -> {}, - new SqmJdbcExecutionContextAdapter( executionContext ) + SqmJdbcExecutionContextAdapter.omittingLockingAndPaging( executionContext ) ); } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SqmJdbcExecutionContextAdapter.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SqmJdbcExecutionContextAdapter.java index 6fc5d65589..058694153d 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SqmJdbcExecutionContextAdapter.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SqmJdbcExecutionContextAdapter.java @@ -17,25 +17,38 @@ import org.hibernate.sql.exec.spi.JdbcSelect; import static org.hibernate.query.spi.SqlOmittingQueryOptions.omitSqlQueryOptions; /** - * @author Steve Ebersole + * ExecutionContext adapter delegating to a DomainQueryExecutionContext */ public class SqmJdbcExecutionContextAdapter implements ExecutionContext { + /** + * Creates an adapter which drops any locking or paging details from the query options + */ + public static SqmJdbcExecutionContextAdapter omittingLockingAndPaging(DomainQueryExecutionContext sqmExecutionContext) { + return new SqmJdbcExecutionContextAdapter( sqmExecutionContext ); + } + + /** + * Creates an adapter which honors any locking or paging details specified in the query options + */ + public static SqmJdbcExecutionContextAdapter usingLockingAndPaging(DomainQueryExecutionContext sqmExecutionContext) { + return new SqmJdbcExecutionContextAdapter( sqmExecutionContext, sqmExecutionContext.getQueryOptions() ); + } + private final DomainQueryExecutionContext sqmExecutionContext; private final QueryOptions queryOptions; - public SqmJdbcExecutionContextAdapter(DomainQueryExecutionContext sqmExecutionContext) { + private SqmJdbcExecutionContextAdapter(DomainQueryExecutionContext sqmExecutionContext) { this( sqmExecutionContext, omitSqlQueryOptions( sqmExecutionContext.getQueryOptions() ) ); } + private SqmJdbcExecutionContextAdapter(DomainQueryExecutionContext sqmExecutionContext, QueryOptions queryOptions) { + this.sqmExecutionContext = sqmExecutionContext; + this.queryOptions = queryOptions; + } + public SqmJdbcExecutionContextAdapter(DomainQueryExecutionContext sqmExecutionContext, JdbcSelect jdbcSelect) { this( sqmExecutionContext, omitSqlQueryOptions( sqmExecutionContext.getQueryOptions(), jdbcSelect ) ); } - - public SqmJdbcExecutionContextAdapter(DomainQueryExecutionContext sqmExecutionContext, QueryOptions queryOptions) { - this.sqmExecutionContext = sqmExecutionContext; - this.queryOptions = queryOptions; - } - @Override public SharedSessionContractImplementor getSession() { return sqmExecutionContext.getSession(); diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/MatchingIdSelectionHelper.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/MatchingIdSelectionHelper.java index f8e0c11e45..325845f933 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/MatchingIdSelectionHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/MatchingIdSelectionHelper.java @@ -275,7 +275,7 @@ public class MatchingIdSelectionHelper { return jdbcServices.getJdbcSelectExecutor().list( idSelectJdbcOperation, jdbcParameterBindings, - new SqmJdbcExecutionContextAdapter( executionContext ), + SqmJdbcExecutionContextAdapter.omittingLockingAndPaging( executionContext ), row -> row, ListResultsConsumer.UniqueSemantic.FILTER ); diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/cte/AbstractCteMutationHandler.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/cte/AbstractCteMutationHandler.java index f86f677a98..928a1e8483 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/cte/AbstractCteMutationHandler.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/cte/AbstractCteMutationHandler.java @@ -206,7 +206,7 @@ public abstract class AbstractCteMutationHandler extends AbstractMutationHandler List list = jdbcServices.getJdbcSelectExecutor().list( select, jdbcParameterBindings, - new SqmJdbcExecutionContextAdapter( executionContext ), + SqmJdbcExecutionContextAdapter.omittingLockingAndPaging( executionContext ), row -> row[0], ListResultsConsumer.UniqueSemantic.NONE ); diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/RestrictedDeleteExecutionDelegate.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/RestrictedDeleteExecutionDelegate.java index 030373c5d8..f915e76991 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/RestrictedDeleteExecutionDelegate.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/RestrictedDeleteExecutionDelegate.java @@ -34,7 +34,6 @@ import org.hibernate.persister.entity.Joinable; import org.hibernate.query.spi.DomainQueryExecutionContext; import org.hibernate.query.spi.QueryOptions; import org.hibernate.query.spi.QueryParameterBindings; -import org.hibernate.query.spi.SqlOmittingQueryOptions; import org.hibernate.query.sqm.internal.DomainParameterXref; import org.hibernate.query.sqm.internal.SqmJdbcExecutionContextAdapter; import org.hibernate.query.sqm.internal.SqmUtil; @@ -178,7 +177,7 @@ public class RestrictedDeleteExecutionDelegate implements TableBasedDeleteHandle boolean needsIdTable = needsIdTableWrapper.get(); - final SqmJdbcExecutionContextAdapter executionContextAdapter = new SqmJdbcExecutionContextAdapter( executionContext ); + final SqmJdbcExecutionContextAdapter executionContextAdapter = SqmJdbcExecutionContextAdapter.omittingLockingAndPaging( executionContext ); if ( needsIdTable ) { return executeWithIdTable( diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/TableBasedUpdateHandler.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/TableBasedUpdateHandler.java index 061aff908e..587fdaa360 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/TableBasedUpdateHandler.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/TableBasedUpdateHandler.java @@ -110,7 +110,7 @@ public class TableBasedUpdateHandler ); } - final SqmJdbcExecutionContextAdapter executionContextAdapter = new SqmJdbcExecutionContextAdapter( executionContext ); + final SqmJdbcExecutionContextAdapter executionContextAdapter = SqmJdbcExecutionContextAdapter.omittingLockingAndPaging( executionContext ); return resolveDelegate( executionContext ).execute( executionContextAdapter ); } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/inline/InlineDeleteHandler.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/inline/InlineDeleteHandler.java index 1456441366..5bb2c2ab26 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/inline/InlineDeleteHandler.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/inline/InlineDeleteHandler.java @@ -148,7 +148,7 @@ public class InlineDeleteHandler implements DeleteHandler { sessionFactory ); - final SqmJdbcExecutionContextAdapter executionContextAdapter = new SqmJdbcExecutionContextAdapter( executionContext ); + final SqmJdbcExecutionContextAdapter executionContextAdapter = SqmJdbcExecutionContextAdapter.omittingLockingAndPaging( executionContext ); final Predicate matchingIdsPredicate = matchingIdsPredicateProducer.produceRestriction( ids,