HHH-14877 - FetchMode.SUBSELECT ignored

- cleanup
This commit is contained in:
Steve Ebersole 2021-10-21 16:47:09 -05:00
parent aef0775946
commit a3c36af5c6
12 changed files with 32 additions and 21 deletions

View File

@ -6,7 +6,6 @@
*/
package org.hibernate.loader.ast.internal;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

View File

@ -109,7 +109,7 @@ public class NativeNonSelectQueryPlanImpl implements NonSelectQueryPlan {
.getStatementPreparer()
.prepareStatement( sql ),
(integer, preparedStatement) -> {},
new SqmJdbcExecutionContextAdapter( executionContext )
SqmJdbcExecutionContextAdapter.usingLockingAndPaging( executionContext )
);
}
}

View File

@ -127,7 +127,7 @@ public class NativeSelectQueryPlanImpl<R> implements NativeSelectQueryPlan<R> {
return executor.list(
jdbcSelect,
jdbcParameterBindings,
new SqmJdbcExecutionContextAdapter( executionContext, executionContext.getQueryOptions() ),
SqmJdbcExecutionContextAdapter.usingLockingAndPaging( executionContext ),
null,
ListResultsConsumer.UniqueSemantic.NONE
);
@ -192,7 +192,7 @@ public class NativeSelectQueryPlanImpl<R> implements NativeSelectQueryPlan<R> {
jdbcSelect,
scrollMode,
jdbcParameterBindings,
new SqmJdbcExecutionContextAdapter( executionContext, executionContext.getQueryOptions() ),
SqmJdbcExecutionContextAdapter.usingLockingAndPaging( executionContext ),
null
);
}

View File

@ -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,

View File

@ -123,7 +123,7 @@ public class SimpleInsertQueryPlan implements NonSelectQueryPlan {
.getStatementPreparer()
.prepareStatement( sql ),
(integer, preparedStatement) -> {},
new SqmJdbcExecutionContextAdapter( executionContext )
SqmJdbcExecutionContextAdapter.omittingLockingAndPaging( executionContext )
);
}
}

View File

@ -92,7 +92,7 @@ public class SimpleUpdateQueryPlan implements NonSelectQueryPlan {
.getStatementPreparer()
.prepareStatement( sql ),
(integer, preparedStatement) -> {},
new SqmJdbcExecutionContextAdapter( executionContext )
SqmJdbcExecutionContextAdapter.omittingLockingAndPaging( executionContext )
);
}

View File

@ -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();

View File

@ -275,7 +275,7 @@ public class MatchingIdSelectionHelper {
return jdbcServices.getJdbcSelectExecutor().list(
idSelectJdbcOperation,
jdbcParameterBindings,
new SqmJdbcExecutionContextAdapter( executionContext ),
SqmJdbcExecutionContextAdapter.omittingLockingAndPaging( executionContext ),
row -> row,
ListResultsConsumer.UniqueSemantic.FILTER
);

View File

@ -206,7 +206,7 @@ public abstract class AbstractCteMutationHandler extends AbstractMutationHandler
List<Object> list = jdbcServices.getJdbcSelectExecutor().list(
select,
jdbcParameterBindings,
new SqmJdbcExecutionContextAdapter( executionContext ),
SqmJdbcExecutionContextAdapter.omittingLockingAndPaging( executionContext ),
row -> row[0],
ListResultsConsumer.UniqueSemantic.NONE
);

View File

@ -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(

View File

@ -110,7 +110,7 @@ public class TableBasedUpdateHandler
);
}
final SqmJdbcExecutionContextAdapter executionContextAdapter = new SqmJdbcExecutionContextAdapter( executionContext );
final SqmJdbcExecutionContextAdapter executionContextAdapter = SqmJdbcExecutionContextAdapter.omittingLockingAndPaging( executionContext );
return resolveDelegate( executionContext ).execute( executionContextAdapter );
}

View File

@ -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,