Allow controlling whether selection item deduplication should happen and disable deduplication in subqueries. Remove some dead code and fix a possible NPE. Expose some JdbcOperation fields for libraries to make it easy to produce a derived operation.
This commit is contained in:
parent
ef391bf644
commit
af42f3a76c
|
@ -196,14 +196,16 @@ public class InformixDialect extends Dialect {
|
|||
DomainParameterXref domainParameterXref,
|
||||
QueryParameterBindings domainParameterBindings,
|
||||
LoadQueryInfluencers loadQueryInfluencers,
|
||||
SqlAstCreationContext creationContext) {
|
||||
SqlAstCreationContext creationContext,
|
||||
boolean deduplicateSelectionItems) {
|
||||
return new InformixSqmToSqlAstConverter<>(
|
||||
sqmSelectStatement,
|
||||
queryOptions,
|
||||
domainParameterXref,
|
||||
domainParameterBindings,
|
||||
loadQueryInfluencers,
|
||||
creationContext
|
||||
creationContext,
|
||||
deduplicateSelectionItems
|
||||
);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -37,8 +37,17 @@ public class InformixSqmToSqlAstConverter<T extends Statement> extends BaseSqmTo
|
|||
DomainParameterXref domainParameterXref,
|
||||
QueryParameterBindings domainParameterBindings,
|
||||
LoadQueryInfluencers fetchInfluencers,
|
||||
SqlAstCreationContext creationContext) {
|
||||
super( creationContext, statement, queryOptions, fetchInfluencers, domainParameterXref, domainParameterBindings );
|
||||
SqlAstCreationContext creationContext,
|
||||
boolean deduplicateSelectionItems) {
|
||||
super(
|
||||
creationContext,
|
||||
statement,
|
||||
queryOptions,
|
||||
fetchInfluencers,
|
||||
domainParameterXref,
|
||||
domainParameterBindings,
|
||||
deduplicateSelectionItems
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -311,14 +311,16 @@ public class IngresDialect extends Dialect {
|
|||
DomainParameterXref domainParameterXref,
|
||||
QueryParameterBindings domainParameterBindings,
|
||||
LoadQueryInfluencers loadQueryInfluencers,
|
||||
SqlAstCreationContext creationContext) {
|
||||
SqlAstCreationContext creationContext,
|
||||
boolean deduplicateSelectionItems) {
|
||||
return new IngresSqmToSqlAstConverter<>(
|
||||
sqmSelectStatement,
|
||||
queryOptions,
|
||||
domainParameterXref,
|
||||
domainParameterBindings,
|
||||
loadQueryInfluencers,
|
||||
creationContext
|
||||
creationContext,
|
||||
deduplicateSelectionItems
|
||||
);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -37,8 +37,17 @@ public class IngresSqmToSqlAstConverter<T extends Statement> extends BaseSqmToSq
|
|||
DomainParameterXref domainParameterXref,
|
||||
QueryParameterBindings domainParameterBindings,
|
||||
LoadQueryInfluencers fetchInfluencers,
|
||||
SqlAstCreationContext creationContext) {
|
||||
super( creationContext, statement, queryOptions, fetchInfluencers, domainParameterXref, domainParameterBindings );
|
||||
SqlAstCreationContext creationContext,
|
||||
boolean deduplicateSelectionItems) {
|
||||
super(
|
||||
creationContext,
|
||||
statement,
|
||||
queryOptions,
|
||||
fetchInfluencers,
|
||||
domainParameterXref,
|
||||
domainParameterBindings,
|
||||
deduplicateSelectionItems
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -123,14 +123,16 @@ public class SybaseDialect extends AbstractTransactSQLDialect {
|
|||
DomainParameterXref domainParameterXref,
|
||||
QueryParameterBindings domainParameterBindings,
|
||||
LoadQueryInfluencers loadQueryInfluencers,
|
||||
SqlAstCreationContext creationContext) {
|
||||
SqlAstCreationContext creationContext,
|
||||
boolean deduplicateSelectionItems) {
|
||||
return new SybaseSqmToSqlAstConverter<>(
|
||||
sqmSelectStatement,
|
||||
queryOptions,
|
||||
domainParameterXref,
|
||||
domainParameterBindings,
|
||||
loadQueryInfluencers,
|
||||
creationContext
|
||||
creationContext,
|
||||
deduplicateSelectionItems
|
||||
);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -37,8 +37,17 @@ public class SybaseSqmToSqlAstConverter<T extends Statement> extends BaseSqmToSq
|
|||
DomainParameterXref domainParameterXref,
|
||||
QueryParameterBindings domainParameterBindings,
|
||||
LoadQueryInfluencers fetchInfluencers,
|
||||
SqlAstCreationContext creationContext) {
|
||||
super( creationContext, statement, queryOptions, fetchInfluencers, domainParameterXref, domainParameterBindings );
|
||||
SqlAstCreationContext creationContext,
|
||||
boolean deduplicateSelectionItems) {
|
||||
super(
|
||||
creationContext,
|
||||
statement,
|
||||
queryOptions,
|
||||
fetchInfluencers,
|
||||
domainParameterXref,
|
||||
domainParameterBindings,
|
||||
deduplicateSelectionItems
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -78,7 +78,8 @@ public class LoaderSqlAstCreationState
|
|||
queryPart,
|
||||
this,
|
||||
this,
|
||||
() -> Clause.IRRELEVANT
|
||||
() -> Clause.IRRELEVANT,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -365,7 +365,8 @@ public class ConcreteSqmSelectQueryPlan<R> implements SelectQueryPlan<R> {
|
|||
domainParameterXref,
|
||||
executionContext.getQueryParameterBindings(),
|
||||
executionContext.getSession().getLoadQueryInfluencers(),
|
||||
sessionFactory
|
||||
sessionFactory,
|
||||
true
|
||||
);
|
||||
|
||||
// tableGroupAccess = sqmConverter.getFromClauseAccess();
|
||||
|
|
|
@ -96,7 +96,8 @@ public class MatchingIdSelectionHelper {
|
|||
idSelectionQuery,
|
||||
sqmConverter.getCurrentProcessingState(),
|
||||
sqmConverter.getSqlAstCreationState(),
|
||||
sqmConverter.getCurrentClauseStack()::getCurrent
|
||||
sqmConverter.getCurrentClauseStack()::getCurrent,
|
||||
false
|
||||
)
|
||||
);
|
||||
targetEntityDescriptor.getIdentifierMapping().applySqlSelections(
|
||||
|
@ -240,7 +241,8 @@ public class MatchingIdSelectionHelper {
|
|||
matchingIdSelection.getQuerySpec(),
|
||||
sqmConverter.getCurrentProcessingState(),
|
||||
sqmConverter.getSqlAstCreationState(),
|
||||
sqmConverter.getCurrentClauseStack()::getCurrent
|
||||
sqmConverter.getCurrentClauseStack()::getCurrent,
|
||||
true
|
||||
)
|
||||
);
|
||||
entityDescriptor.visitSubTypeAttributeMappings(
|
||||
|
|
|
@ -20,15 +20,12 @@ import org.hibernate.query.spi.QueryOptions;
|
|||
import org.hibernate.query.spi.QueryParameterBindings;
|
||||
import org.hibernate.query.sqm.internal.DomainParameterXref;
|
||||
import org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter;
|
||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
||||
import org.hibernate.query.sqm.sql.internal.SqlAstProcessingStateImpl;
|
||||
import org.hibernate.query.sqm.sql.internal.SqlAstQueryPartProcessingStateImpl;
|
||||
import org.hibernate.query.sqm.tree.SqmStatement;
|
||||
import org.hibernate.query.sqm.tree.expression.SqmParameter;
|
||||
import org.hibernate.query.sqm.tree.from.SqmRoot;
|
||||
import org.hibernate.query.sqm.tree.insert.SqmInsertStatement;
|
||||
import org.hibernate.query.sqm.tree.predicate.SqmWhereClause;
|
||||
import org.hibernate.query.sqm.tree.select.SqmSelectClause;
|
||||
import org.hibernate.query.sqm.tree.update.SqmAssignment;
|
||||
import org.hibernate.query.sqm.tree.update.SqmSetClause;
|
||||
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||
|
@ -40,7 +37,6 @@ import org.hibernate.sql.ast.tree.expression.Expression;
|
|||
import org.hibernate.sql.ast.tree.expression.JdbcParameter;
|
||||
import org.hibernate.sql.ast.tree.from.TableGroup;
|
||||
import org.hibernate.sql.ast.tree.predicate.Predicate;
|
||||
import org.hibernate.sql.ast.tree.select.QuerySpec;
|
||||
import org.hibernate.sql.ast.tree.update.Assignable;
|
||||
import org.hibernate.sql.ast.tree.update.Assignment;
|
||||
|
||||
|
@ -51,7 +47,6 @@ import org.hibernate.sql.ast.tree.update.Assignment;
|
|||
*
|
||||
* @see #visitSetClause(SqmSetClause, Consumer, SqmParameterResolutionConsumer)
|
||||
* @see #visitWhereClause(SqmWhereClause, Consumer, SqmParameterResolutionConsumer)
|
||||
* @see #visitSelectClause(SqmSelectClause, QuerySpec, Consumer, SqmParameterResolutionConsumer)
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
|
@ -97,7 +92,15 @@ public class MultiTableSqmMutationConverter extends BaseSqmToSqlAstConverter<Sta
|
|||
LoadQueryInfluencers loadQueryInfluencers,
|
||||
QueryParameterBindings domainParameterBindings,
|
||||
SqlAstCreationContext creationContext) {
|
||||
super( creationContext, statement, queryOptions, loadQueryInfluencers, domainParameterXref, domainParameterBindings );
|
||||
super(
|
||||
creationContext,
|
||||
statement,
|
||||
queryOptions,
|
||||
loadQueryInfluencers,
|
||||
domainParameterXref,
|
||||
domainParameterBindings,
|
||||
false
|
||||
);
|
||||
this.mutatingEntityDescriptor = mutatingEntityDescriptor;
|
||||
|
||||
final SqlAstProcessingStateImpl rootProcessingState = new SqlAstProcessingStateImpl(
|
||||
|
@ -247,59 +250,4 @@ public class MultiTableSqmMutationConverter extends BaseSqmToSqlAstConverter<Sta
|
|||
return expression;
|
||||
}
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
public void visitSelectClause(
|
||||
SqmSelectClause sqmSelectClause,
|
||||
QuerySpec sqlQuerySpec,
|
||||
Consumer<ColumnReference> columnReferenceConsumer,
|
||||
SqmParameterResolutionConsumer parameterResolutionConsumer) {
|
||||
assert sqmSelectClause != null;
|
||||
|
||||
this.parameterResolutionConsumer = parameterResolutionConsumer;
|
||||
|
||||
final SqlAstProcessingState rootProcessingState = getCurrentProcessingState();
|
||||
final SqlAstProcessingStateImpl processingState = new SqlAstQueryPartProcessingStateImpl(
|
||||
sqlQuerySpec,
|
||||
rootProcessingState,
|
||||
this,
|
||||
r -> new SqmAliasedNodePositionTracker(
|
||||
r,
|
||||
sqmSelectClause.getSelections()
|
||||
),
|
||||
getCurrentClauseStack()::getCurrent
|
||||
) {
|
||||
@Override
|
||||
public SqlExpressionResolver getSqlExpressionResolver() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Expression resolveSqlExpression(
|
||||
String key, Function<SqlAstProcessingState, Expression> creator) {
|
||||
final Expression expression = rootProcessingState.getSqlExpressionResolver().resolveSqlExpression(
|
||||
key,
|
||||
creator
|
||||
);
|
||||
if ( expression instanceof ColumnReference ) {
|
||||
columnReferenceConsumer.accept( (ColumnReference) expression );
|
||||
}
|
||||
return expression;
|
||||
}
|
||||
};
|
||||
|
||||
pushProcessingState( processingState, getFromClauseIndex() );
|
||||
try {
|
||||
for ( int i = 0; i < sqmSelectClause.getSelectionItems().size(); i++ ) {
|
||||
final DomainResultProducer<?> domainResultProducer = (DomainResultProducer<?>) sqmSelectClause.getSelectionItems()
|
||||
.get( i )
|
||||
.accept( this );
|
||||
domainResultProducer.applySqlSelections( this );
|
||||
}
|
||||
}
|
||||
finally {
|
||||
popProcessingStateStack();
|
||||
this.parameterResolutionConsumer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,8 @@ public class CteDeleteHandler extends AbstractCteMutationHandler implements Dele
|
|||
idSelectStatement.getQuerySpec(),
|
||||
sqmConverter.getCurrentProcessingState(),
|
||||
sqmConverter.getSqlAstCreationState(),
|
||||
sqmConverter.getCurrentClauseStack()::getCurrent
|
||||
sqmConverter.getCurrentClauseStack()::getCurrent,
|
||||
false
|
||||
)
|
||||
);
|
||||
getEntityDescriptor().visitSubTypeAttributeMappings(
|
||||
|
|
|
@ -395,6 +395,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
private int fetchDepth;
|
||||
private String currentBagRole;
|
||||
private boolean resolvingCircularFetch;
|
||||
private boolean deduplicateSelectionItems;
|
||||
private ForeignKeyDescriptor.Nature currentlyResolvingForeignKeySide;
|
||||
private SqmQueryPart<?> currentSqmQueryPart;
|
||||
private boolean containsCollectionFetches;
|
||||
|
@ -423,7 +424,8 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
QueryOptions queryOptions,
|
||||
LoadQueryInfluencers loadQueryInfluencers,
|
||||
DomainParameterXref domainParameterXref,
|
||||
QueryParameterBindings domainParameterBindings) {
|
||||
QueryParameterBindings domainParameterBindings,
|
||||
boolean deduplicateSelectionItems) {
|
||||
super( creationContext.getServiceRegistry() );
|
||||
|
||||
this.creationContext = creationContext;
|
||||
|
@ -434,6 +436,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
.isJpaQueryComplianceEnabled();
|
||||
|
||||
this.statement = statement;
|
||||
this.deduplicateSelectionItems = deduplicateSelectionItems;
|
||||
|
||||
if ( statement instanceof SqmSelectStatement<?> ) {
|
||||
// NOTE: note the difference here between `JpaSelection#getSelectionItems`
|
||||
|
@ -1586,7 +1589,8 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
getCurrentProcessingState(),
|
||||
this,
|
||||
DelegatingSqmAliasedNodeCollector::new,
|
||||
currentClauseStack::getCurrent
|
||||
currentClauseStack::getCurrent,
|
||||
deduplicateSelectionItems
|
||||
);
|
||||
final DelegatingSqmAliasedNodeCollector collector = (DelegatingSqmAliasedNodeCollector) processingState
|
||||
.getSqlExpressionResolver();
|
||||
|
@ -1656,7 +1660,8 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
r,
|
||||
selectClause.getSelections()
|
||||
),
|
||||
currentClauseStack::getCurrent
|
||||
currentClauseStack::getCurrent,
|
||||
deduplicateSelectionItems
|
||||
);
|
||||
}
|
||||
else {
|
||||
|
@ -1664,12 +1669,16 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
sqlQuerySpec,
|
||||
getCurrentProcessingState(),
|
||||
this,
|
||||
currentClauseStack::getCurrent
|
||||
currentClauseStack::getCurrent,
|
||||
deduplicateSelectionItems
|
||||
);
|
||||
}
|
||||
|
||||
final SqmQueryPart<?> sqmQueryPart = currentSqmQueryPart;
|
||||
final boolean originalDeduplicateSelectionItems = deduplicateSelectionItems;
|
||||
currentSqmQueryPart = sqmQuerySpec;
|
||||
// In sub-queries, we can never deduplicate the selection items as that might change semantics
|
||||
deduplicateSelectionItems = false;
|
||||
pushProcessingState( processingState );
|
||||
|
||||
try {
|
||||
|
@ -1719,6 +1728,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
additionalRestrictions = originalAdditionalRestrictions;
|
||||
popProcessingStateStack();
|
||||
currentSqmQueryPart = sqmQueryPart;
|
||||
deduplicateSelectionItems = originalDeduplicateSelectionItems;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3370,7 +3380,8 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
subQuerySpec,
|
||||
getCurrentProcessingState(),
|
||||
this,
|
||||
currentClauseStack::getCurrent
|
||||
currentClauseStack::getCurrent,
|
||||
false
|
||||
)
|
||||
);
|
||||
try {
|
||||
|
@ -3518,7 +3529,8 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
subQuerySpec,
|
||||
getCurrentProcessingState(),
|
||||
this,
|
||||
currentClauseStack::getCurrent
|
||||
currentClauseStack::getCurrent,
|
||||
false
|
||||
)
|
||||
);
|
||||
try {
|
||||
|
@ -3646,7 +3658,8 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
subQuerySpec,
|
||||
getCurrentProcessingState(),
|
||||
this,
|
||||
currentClauseStack::getCurrent
|
||||
currentClauseStack::getCurrent,
|
||||
false
|
||||
)
|
||||
);
|
||||
try {
|
||||
|
@ -5365,7 +5378,8 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
subQuerySpec,
|
||||
getCurrentProcessingState(),
|
||||
this,
|
||||
currentClauseStack::getCurrent
|
||||
currentClauseStack::getCurrent,
|
||||
false
|
||||
)
|
||||
);
|
||||
try {
|
||||
|
|
|
@ -31,7 +31,8 @@ public interface SqmTranslatorFactory {
|
|||
DomainParameterXref domainParameterXref,
|
||||
QueryParameterBindings domainParameterBindings,
|
||||
LoadQueryInfluencers loadQueryInfluencers,
|
||||
SqlAstCreationContext creationContext);
|
||||
SqlAstCreationContext creationContext,
|
||||
boolean deduplicateSelectionItems);
|
||||
|
||||
SqmTranslator<DeleteStatement> createSimpleDeleteTranslator(
|
||||
SqmDeleteStatement<?> sqmDeleteStatement,
|
||||
|
|
|
@ -35,14 +35,16 @@ public class StandardSqmTranslatorFactory implements SqmTranslatorFactory {
|
|||
DomainParameterXref domainParameterXref,
|
||||
QueryParameterBindings domainParameterBindings,
|
||||
LoadQueryInfluencers loadQueryInfluencers,
|
||||
SqlAstCreationContext creationContext) {
|
||||
SqlAstCreationContext creationContext,
|
||||
boolean deduplicateSelectionItems) {
|
||||
return new StandardSqmTranslator<>(
|
||||
sqmSelectStatement,
|
||||
queryOptions,
|
||||
domainParameterXref,
|
||||
domainParameterBindings,
|
||||
loadQueryInfluencers,
|
||||
creationContext
|
||||
creationContext,
|
||||
deduplicateSelectionItems
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -60,7 +62,8 @@ public class StandardSqmTranslatorFactory implements SqmTranslatorFactory {
|
|||
domainParameterXref,
|
||||
domainParameterBindings,
|
||||
loadQueryInfluencers,
|
||||
creationContext
|
||||
creationContext,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -78,7 +81,8 @@ public class StandardSqmTranslatorFactory implements SqmTranslatorFactory {
|
|||
domainParameterXref,
|
||||
domainParameterBindings,
|
||||
loadQueryInfluencers,
|
||||
creationContext
|
||||
creationContext,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -96,7 +100,8 @@ public class StandardSqmTranslatorFactory implements SqmTranslatorFactory {
|
|||
domainParameterXref,
|
||||
domainParameterBindings,
|
||||
loadQueryInfluencers,
|
||||
creationContext
|
||||
creationContext,
|
||||
false
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.hibernate.sql.ast.spi.SqlSelection;
|
|||
import org.hibernate.sql.ast.tree.expression.Expression;
|
||||
import org.hibernate.sql.ast.tree.select.QueryPart;
|
||||
import org.hibernate.sql.ast.tree.select.QuerySpec;
|
||||
import org.hibernate.sql.ast.tree.select.SelectClause;
|
||||
import org.hibernate.type.descriptor.java.JavaType;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
|
@ -31,14 +32,17 @@ public class SqlAstQueryPartProcessingStateImpl
|
|||
implements SqlAstQueryPartProcessingState {
|
||||
|
||||
private final QueryPart queryPart;
|
||||
private final boolean deduplicateSelectionItems;
|
||||
|
||||
public SqlAstQueryPartProcessingStateImpl(
|
||||
QueryPart queryPart,
|
||||
SqlAstProcessingState parent,
|
||||
SqlAstCreationState creationState,
|
||||
Supplier<Clause> currentClauseAccess) {
|
||||
Supplier<Clause> currentClauseAccess,
|
||||
boolean deduplicateSelectionItems) {
|
||||
super( parent, creationState, currentClauseAccess );
|
||||
this.queryPart = queryPart;
|
||||
this.deduplicateSelectionItems = deduplicateSelectionItems;
|
||||
}
|
||||
|
||||
public SqlAstQueryPartProcessingStateImpl(
|
||||
|
@ -46,9 +50,11 @@ public class SqlAstQueryPartProcessingStateImpl
|
|||
SqlAstProcessingState parent,
|
||||
SqlAstCreationState creationState,
|
||||
Function<SqlExpressionResolver, SqlExpressionResolver> expressionResolverDecorator,
|
||||
Supplier<Clause> currentClauseAccess) {
|
||||
Supplier<Clause> currentClauseAccess,
|
||||
boolean deduplicateSelectionItems) {
|
||||
super( parent, creationState, expressionResolverDecorator, currentClauseAccess );
|
||||
this.queryPart = queryPart;
|
||||
this.deduplicateSelectionItems = deduplicateSelectionItems;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -79,11 +85,12 @@ public class SqlAstQueryPartProcessingStateImpl
|
|||
existing = sqlSelectionMap.get( expression );
|
||||
}
|
||||
|
||||
if ( existing != null ) {
|
||||
if ( existing != null && deduplicateSelectionItems ) {
|
||||
return existing;
|
||||
}
|
||||
|
||||
final int valuesArrayPosition = sqlSelectionMap.size();
|
||||
final SelectClause selectClause = ( (QuerySpec) queryPart ).getSelectClause();
|
||||
final int valuesArrayPosition = selectClause.getSqlSelections().size();
|
||||
final SqlSelection sqlSelection = expression.createSqlSelection(
|
||||
valuesArrayPosition + 1,
|
||||
valuesArrayPosition,
|
||||
|
@ -93,7 +100,7 @@ public class SqlAstQueryPartProcessingStateImpl
|
|||
|
||||
sqlSelectionMap.put( expression, sqlSelection );
|
||||
|
||||
( (QuerySpec) queryPart ).getSelectClause().addSqlSelection( sqlSelection );
|
||||
selectClause.addSqlSelection( sqlSelection );
|
||||
|
||||
return sqlSelection;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ import org.hibernate.query.spi.QueryOptions;
|
|||
import org.hibernate.query.spi.QueryParameterBindings;
|
||||
import org.hibernate.query.sqm.internal.DomainParameterXref;
|
||||
import org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter;
|
||||
import org.hibernate.query.sqm.sql.SqmTranslation;
|
||||
import org.hibernate.query.sqm.tree.SqmStatement;
|
||||
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||
import org.hibernate.sql.ast.tree.Statement;
|
||||
|
@ -29,7 +28,16 @@ public class StandardSqmTranslator<T extends Statement> extends BaseSqmToSqlAstC
|
|||
DomainParameterXref domainParameterXref,
|
||||
QueryParameterBindings domainParameterBindings,
|
||||
LoadQueryInfluencers fetchInfluencers,
|
||||
SqlAstCreationContext creationContext) {
|
||||
super( creationContext, statement, queryOptions, fetchInfluencers, domainParameterXref, domainParameterBindings );
|
||||
SqlAstCreationContext creationContext,
|
||||
boolean deduplicateSelectionItems) {
|
||||
super(
|
||||
creationContext,
|
||||
statement,
|
||||
queryOptions,
|
||||
fetchInfluencers,
|
||||
domainParameterXref,
|
||||
domainParameterBindings,
|
||||
deduplicateSelectionItems
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1012,7 +1012,7 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
|
|||
protected void visitForUpdateClause(QuerySpec querySpec) {
|
||||
if ( querySpec.isRoot() ) {
|
||||
if ( forUpdate != null ) {
|
||||
final Boolean followOnLocking = getLockOptions().getFollowOnLocking();
|
||||
final Boolean followOnLocking = getLockOptions() == null ? Boolean.FALSE : getLockOptions().getFollowOnLocking();
|
||||
if ( Boolean.TRUE.equals( followOnLocking ) ) {
|
||||
lockOptions = null;
|
||||
}
|
||||
|
@ -1041,7 +1041,7 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
|
|||
// Since we get here, we know that no alias locks were applied.
|
||||
// We only apply locking on the root query though if there is a global lock mode
|
||||
final LockOptions lockOptions = getLockOptions();
|
||||
final Boolean followOnLocking = lockOptions.getFollowOnLocking();
|
||||
final Boolean followOnLocking = getLockOptions() == null ? Boolean.FALSE : lockOptions.getFollowOnLocking();
|
||||
if ( Boolean.TRUE.equals( followOnLocking ) ) {
|
||||
this.lockOptions = null;
|
||||
}
|
||||
|
@ -1184,6 +1184,9 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
|
|||
}
|
||||
|
||||
protected LockMode getEffectiveLockMode(String alias) {
|
||||
if ( getLockOptions() == null ) {
|
||||
return LockMode.NONE;
|
||||
}
|
||||
final QueryPart currentQueryPart = getQueryPartStack().getCurrent();
|
||||
LockMode lockMode = getLockOptions().getAliasSpecificLockMode( alias );
|
||||
if ( currentQueryPart.isRoot() && lockMode == null ) {
|
||||
|
@ -1193,6 +1196,9 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
|
|||
}
|
||||
|
||||
protected int getEffectiveLockTimeout(LockMode lockMode) {
|
||||
if ( getLockOptions() == null ) {
|
||||
return LockOptions.WAIT_FOREVER;
|
||||
}
|
||||
int timeoutMillis = getLockOptions().getTimeOut();
|
||||
switch ( lockMode ) {
|
||||
//noinspection deprecation
|
||||
|
|
|
@ -86,15 +86,6 @@ public class CaseSearchedExpression implements Expression, DomainResultProducer
|
|||
public void applySqlSelections(DomainResultCreationState creationState) {
|
||||
final SqlExpressionResolver sqlExpressionResolver = creationState.getSqlAstCreationState()
|
||||
.getSqlExpressionResolver();
|
||||
final SqlSelection sqlSelection = sqlExpressionResolver
|
||||
.resolveSqlSelection(
|
||||
this,
|
||||
type.getExpressibleJavaType(),
|
||||
creationState.getSqlAstCreationState()
|
||||
.getCreationContext()
|
||||
.getSessionFactory()
|
||||
.getTypeConfiguration()
|
||||
);
|
||||
sqlExpressionResolver.resolveSqlSelection(
|
||||
this,
|
||||
type.getExpressibleJavaType(),
|
||||
|
|
|
@ -79,6 +79,10 @@ public class AbstractJdbcOperation implements JdbcOperation {
|
|||
return !appliedParameters.isEmpty();
|
||||
}
|
||||
|
||||
public Map<JdbcParameter, JdbcParameterBinding> getAppliedParameters() {
|
||||
return appliedParameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompatibleWith(JdbcParameterBindings jdbcParameterBindings, QueryOptions queryOptions) {
|
||||
if ( !appliedParameters.isEmpty() ) {
|
||||
|
|
|
@ -88,6 +88,14 @@ public class JdbcSelect extends AbstractJdbcOperation {
|
|||
return offsetParameter != null || limitParameter != null;
|
||||
}
|
||||
|
||||
public JdbcParameter getOffsetParameter() {
|
||||
return offsetParameter;
|
||||
}
|
||||
|
||||
public JdbcParameter getLimitParameter() {
|
||||
return limitParameter;
|
||||
}
|
||||
|
||||
public JdbcLockStrategy getLockStrategy() {
|
||||
return jdbcLockStrategy;
|
||||
}
|
||||
|
|
|
@ -384,7 +384,8 @@ public class CriteriaEntityGraphTest implements SessionFactoryScopeAware {
|
|||
( (QuerySqmImpl<?>) hqlQuery ).getDomainParameterXref(),
|
||||
query.getParameterBindings(),
|
||||
loadQueryInfluencers,
|
||||
session.getSessionFactory()
|
||||
session.getSessionFactory(),
|
||||
true
|
||||
);
|
||||
|
||||
final SqmTranslation<SelectStatement> sqmInterpretation = sqmConverter.translate();
|
||||
|
|
|
@ -381,7 +381,8 @@ public class HqlEntityGraphTest implements SessionFactoryScopeAware {
|
|||
( (QuerySqmImpl<?>) hqlQuery ).getDomainParameterXref(),
|
||||
query.getParameterBindings(),
|
||||
loadQueryInfluencers,
|
||||
session.getSessionFactory()
|
||||
session.getSessionFactory(),
|
||||
true
|
||||
);
|
||||
|
||||
final SqmTranslation<SelectStatement> sqmInterpretation = sqmConverter.translate();
|
||||
|
|
|
@ -192,8 +192,9 @@ public class EntityJoinTest {
|
|||
DomainParameterXref.empty(),
|
||||
QueryParameterBindings.NO_PARAM_BINDINGS,
|
||||
LoadQueryInfluencers.NONE,
|
||||
factory
|
||||
);
|
||||
factory,
|
||||
true
|
||||
);
|
||||
final SqmTranslation<SelectStatement> sqmTranslation = selectTranslator.translate();
|
||||
|
||||
final SelectStatement sqlAst = sqmTranslation.getSqlAst();
|
||||
|
|
|
@ -84,7 +84,8 @@ public class SmokeTests {
|
|||
( (QuerySqmImpl<?>) hqlQuery ).getDomainParameterXref(),
|
||||
query.getParameterBindings(),
|
||||
session.getLoadQueryInfluencers(),
|
||||
scope.getSessionFactory()
|
||||
scope.getSessionFactory(),
|
||||
true
|
||||
);
|
||||
|
||||
final SqmTranslation<SelectStatement> sqmInterpretation = sqmConverter.translate();
|
||||
|
@ -143,7 +144,8 @@ public class SmokeTests {
|
|||
( (QuerySqmImpl<?>) hqlQuery ).getDomainParameterXref(),
|
||||
query.getParameterBindings(),
|
||||
session.getLoadQueryInfluencers(),
|
||||
scope.getSessionFactory()
|
||||
scope.getSessionFactory(),
|
||||
true
|
||||
);
|
||||
|
||||
final SqmTranslation<SelectStatement> sqmInterpretation = sqmConverter.translate();
|
||||
|
|
|
@ -37,7 +37,8 @@ public class AbstractResultTests {
|
|||
DomainParameterXref.from( sqm ),
|
||||
parameterBindings,
|
||||
LoadQueryInfluencers.NONE,
|
||||
sessionFactory
|
||||
sessionFactory,
|
||||
true
|
||||
);
|
||||
|
||||
return sqmConverter.translate().getSqlAst();
|
||||
|
|
Loading…
Reference in New Issue