clean up lots of warnings by adding wildcards to raw types
also comment out some unused code
This commit is contained in:
parent
4b5e6e1969
commit
3e8f1c67df
|
@ -59,14 +59,14 @@ public class AvgFunction extends AbstractSqmSelfRenderingFunctionDescriptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(SqlAppender sqlAppender, List<SqlAstNode> sqlAstArguments, SqlAstTranslator<?> walker) {
|
public void render(SqlAppender sqlAppender, List<? extends SqlAstNode> sqlAstArguments, SqlAstTranslator<?> walker) {
|
||||||
render( sqlAppender, sqlAstArguments, null, walker );
|
render( sqlAppender, sqlAstArguments, null, walker );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(
|
public void render(
|
||||||
SqlAppender sqlAppender,
|
SqlAppender sqlAppender,
|
||||||
List<SqlAstNode> sqlAstArguments,
|
List<? extends SqlAstNode> sqlAstArguments,
|
||||||
Predicate filter,
|
Predicate filter,
|
||||||
SqlAstTranslator<?> translator) {
|
SqlAstTranslator<?> translator) {
|
||||||
final boolean caseWrapper = filter != null && !translator.supportsFilterClause();
|
final boolean caseWrapper = filter != null && !translator.supportsFilterClause();
|
||||||
|
|
|
@ -10,7 +10,6 @@ import java.util.List;
|
||||||
|
|
||||||
import org.hibernate.query.sqm.function.AbstractSqmSelfRenderingFunctionDescriptor;
|
import org.hibernate.query.sqm.function.AbstractSqmSelfRenderingFunctionDescriptor;
|
||||||
import org.hibernate.query.sqm.produce.function.ArgumentTypesValidator;
|
import org.hibernate.query.sqm.produce.function.ArgumentTypesValidator;
|
||||||
import org.hibernate.query.sqm.produce.function.FunctionParameterType;
|
|
||||||
import org.hibernate.query.sqm.produce.function.StandardArgumentsValidators;
|
import org.hibernate.query.sqm.produce.function.StandardArgumentsValidators;
|
||||||
import org.hibernate.query.sqm.produce.function.StandardFunctionReturnTypeResolvers;
|
import org.hibernate.query.sqm.produce.function.StandardFunctionReturnTypeResolvers;
|
||||||
import org.hibernate.sql.ast.SqlAstTranslator;
|
import org.hibernate.sql.ast.SqlAstTranslator;
|
||||||
|
@ -40,7 +39,7 @@ public class CaseLeastGreatestEmulation
|
||||||
@Override
|
@Override
|
||||||
public void render(
|
public void render(
|
||||||
SqlAppender sqlAppender,
|
SqlAppender sqlAppender,
|
||||||
List<SqlAstNode> arguments,
|
List<? extends SqlAstNode> arguments,
|
||||||
SqlAstTranslator<?> walker) {
|
SqlAstTranslator<?> walker) {
|
||||||
final int numberOfArguments = arguments.size();
|
final int numberOfArguments = arguments.size();
|
||||||
if ( numberOfArguments > 1 ) {
|
if ( numberOfArguments > 1 ) {
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class CaseWhenEveryAnyEmulation extends AbstractSqmSelfRenderingFunctionD
|
||||||
@Override
|
@Override
|
||||||
public void render(
|
public void render(
|
||||||
SqlAppender sqlAppender,
|
SqlAppender sqlAppender,
|
||||||
List<SqlAstNode> sqlAstArguments,
|
List<? extends SqlAstNode> sqlAstArguments,
|
||||||
Predicate filter,
|
Predicate filter,
|
||||||
SqlAstTranslator<?> walker) {
|
SqlAstTranslator<?> walker) {
|
||||||
if ( every ) {
|
if ( every ) {
|
||||||
|
@ -66,7 +66,7 @@ public class CaseWhenEveryAnyEmulation extends AbstractSqmSelfRenderingFunctionD
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(
|
public void render(
|
||||||
SqlAppender sqlAppender, List<SqlAstNode> sqlAstArguments, SqlAstTranslator<?> walker) {
|
SqlAppender sqlAppender, List<? extends SqlAstNode> sqlAstArguments, SqlAstTranslator<?> walker) {
|
||||||
this.render( sqlAppender, sqlAstArguments, null, walker );
|
this.render( sqlAppender, sqlAstArguments, null, walker );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class CastFunction extends AbstractSqmSelfRenderingFunctionDescriptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(SqlAppender sqlAppender, List<SqlAstNode> arguments, SqlAstTranslator<?> walker) {
|
public void render(SqlAppender sqlAppender, List<? extends SqlAstNode> arguments, SqlAstTranslator<?> walker) {
|
||||||
final Expression source = (Expression) arguments.get( 0 );
|
final Expression source = (Expression) arguments.get( 0 );
|
||||||
final JdbcMapping sourceMapping = source.getExpressionType().getJdbcMappings().get( 0 );
|
final JdbcMapping sourceMapping = source.getExpressionType().getJdbcMappings().get( 0 );
|
||||||
final CastType sourceType = getCastType( sourceMapping );
|
final CastType sourceType = getCastType( sourceMapping );
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class CastingConcatFunction extends AbstractSqmSelfRenderingFunctionDescr
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(SqlAppender sqlAppender, List<SqlAstNode> sqlAstArguments, SqlAstTranslator<?> walker) {
|
public void render(SqlAppender sqlAppender, List<? extends SqlAstNode> sqlAstArguments, SqlAstTranslator<?> walker) {
|
||||||
sqlAppender.appendSql( '(' );
|
sqlAppender.appendSql( '(' );
|
||||||
renderAsString( sqlAppender, walker, (Expression) sqlAstArguments.get( 0 ) );
|
renderAsString( sqlAppender, walker, (Expression) sqlAstArguments.get( 0 ) );
|
||||||
for ( int i = 1; i < sqlAstArguments.size(); i++ ) {
|
for ( int i = 1; i < sqlAstArguments.size(); i++ ) {
|
||||||
|
|
|
@ -68,14 +68,14 @@ public class CountFunction extends AbstractSqmSelfRenderingFunctionDescriptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(SqlAppender sqlAppender, List<SqlAstNode> sqlAstArguments, SqlAstTranslator<?> walker) {
|
public void render(SqlAppender sqlAppender, List<? extends SqlAstNode> sqlAstArguments, SqlAstTranslator<?> walker) {
|
||||||
render( sqlAppender, sqlAstArguments, null, walker );
|
render( sqlAppender, sqlAstArguments, null, walker );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(
|
public void render(
|
||||||
SqlAppender sqlAppender,
|
SqlAppender sqlAppender,
|
||||||
List<SqlAstNode> sqlAstArguments,
|
List<? extends SqlAstNode> sqlAstArguments,
|
||||||
Predicate filter,
|
Predicate filter,
|
||||||
SqlAstTranslator<?> translator) {
|
SqlAstTranslator<?> translator) {
|
||||||
final boolean caseWrapper = filter != null && !translator.supportsFilterClause();
|
final boolean caseWrapper = filter != null && !translator.supportsFilterClause();
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class CurrentFunction
|
||||||
@Override
|
@Override
|
||||||
public void render(
|
public void render(
|
||||||
SqlAppender sqlAppender,
|
SqlAppender sqlAppender,
|
||||||
List<SqlAstNode> arguments,
|
List<? extends SqlAstNode> arguments,
|
||||||
SqlAstTranslator<?> walker) {
|
SqlAstTranslator<?> walker) {
|
||||||
sqlAppender.appendSql( sql );
|
sqlAppender.appendSql( sql );
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class DB2FormatEmulation
|
||||||
@Override
|
@Override
|
||||||
public void render(
|
public void render(
|
||||||
SqlAppender sqlAppender,
|
SqlAppender sqlAppender,
|
||||||
List<SqlAstNode> arguments,
|
List<? extends SqlAstNode> arguments,
|
||||||
SqlAstTranslator<?> walker) {
|
SqlAstTranslator<?> walker) {
|
||||||
final Expression datetime = (Expression) arguments.get(0);
|
final Expression datetime = (Expression) arguments.get(0);
|
||||||
final boolean isTime = TypeConfiguration.getSqlTemporalType( datetime.getExpressionType() ) == TemporalType.TIME;
|
final boolean isTime = TypeConfiguration.getSqlTemporalType( datetime.getExpressionType() ) == TemporalType.TIME;
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class DerbyLpadEmulation
|
||||||
@Override
|
@Override
|
||||||
public void render(
|
public void render(
|
||||||
SqlAppender sqlAppender,
|
SqlAppender sqlAppender,
|
||||||
List<SqlAstNode> arguments,
|
List<? extends SqlAstNode> arguments,
|
||||||
SqlAstTranslator<?> walker) {
|
SqlAstTranslator<?> walker) {
|
||||||
final SqlAstNode string = arguments.get( 0 );
|
final SqlAstNode string = arguments.get( 0 );
|
||||||
final SqlAstNode length = arguments.get( 1 );
|
final SqlAstNode length = arguments.get( 1 );
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class DerbyRpadEmulation
|
||||||
@Override
|
@Override
|
||||||
public void render(
|
public void render(
|
||||||
SqlAppender sqlAppender,
|
SqlAppender sqlAppender,
|
||||||
List<SqlAstNode> arguments,
|
List<? extends SqlAstNode> arguments,
|
||||||
SqlAstTranslator<?> walker) {
|
SqlAstTranslator<?> walker) {
|
||||||
final SqlAstNode string = arguments.get( 0 );
|
final SqlAstNode string = arguments.get( 0 );
|
||||||
final SqlAstNode length = arguments.get( 1 );
|
final SqlAstNode length = arguments.get( 1 );
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class EveryAnyEmulation extends AbstractSqmSelfRenderingFunctionDescripto
|
||||||
@Override
|
@Override
|
||||||
public void render(
|
public void render(
|
||||||
SqlAppender sqlAppender,
|
SqlAppender sqlAppender,
|
||||||
List<SqlAstNode> sqlAstArguments,
|
List<? extends SqlAstNode> sqlAstArguments,
|
||||||
Predicate filter,
|
Predicate filter,
|
||||||
SqlAstTranslator<?> walker) {
|
SqlAstTranslator<?> walker) {
|
||||||
sqlAppender.appendSql( "(sum(case when " );
|
sqlAppender.appendSql( "(sum(case when " );
|
||||||
|
@ -72,7 +72,7 @@ public class EveryAnyEmulation extends AbstractSqmSelfRenderingFunctionDescripto
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(
|
public void render(
|
||||||
SqlAppender sqlAppender, List<SqlAstNode> sqlAstArguments, SqlAstTranslator<?> walker) {
|
SqlAppender sqlAppender, List<? extends SqlAstNode> sqlAstArguments, SqlAstTranslator<?> walker) {
|
||||||
this.render( sqlAppender, sqlAstArguments, null, walker );
|
this.render( sqlAppender, sqlAstArguments, null, walker );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class FieldFunction extends AbstractSqmSelfRenderingFunctionDescriptor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(
|
public void render(
|
||||||
SqlAppender sqlAppender, List<SqlAstNode> sqlAstArguments, SqlAstTranslator<?> walker) {
|
SqlAppender sqlAppender, List<? extends SqlAstNode> sqlAstArguments, SqlAstTranslator<?> walker) {
|
||||||
sqlAppender.appendSql( "field(" );
|
sqlAppender.appendSql( "field(" );
|
||||||
sqlAstArguments.get( 0 ).accept( walker );
|
sqlAstArguments.get( 0 ).accept( walker );
|
||||||
for ( int i = 1; i < sqlAstArguments.size(); i++ ) {
|
for ( int i = 1; i < sqlAstArguments.size(); i++ ) {
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class QuantifiedLeastGreatestEmulation
|
||||||
@Override
|
@Override
|
||||||
public void render(
|
public void render(
|
||||||
SqlAppender sqlAppender,
|
SqlAppender sqlAppender,
|
||||||
List<SqlAstNode> arguments,
|
List<? extends SqlAstNode> arguments,
|
||||||
SqlAstTranslator<?> walker) {
|
SqlAstTranslator<?> walker) {
|
||||||
final int numberOfArguments = arguments.size();
|
final int numberOfArguments = arguments.size();
|
||||||
if ( numberOfArguments > 1 ) {
|
if ( numberOfArguments > 1 ) {
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class SQLServerEveryAnyEmulation extends AbstractSqmSelfRenderingFunction
|
||||||
@Override
|
@Override
|
||||||
public void render(
|
public void render(
|
||||||
SqlAppender sqlAppender,
|
SqlAppender sqlAppender,
|
||||||
List<SqlAstNode> sqlAstArguments,
|
List<? extends SqlAstNode> sqlAstArguments,
|
||||||
Predicate filter,
|
Predicate filter,
|
||||||
SqlAstTranslator<?> walker) {
|
SqlAstTranslator<?> walker) {
|
||||||
if ( every ) {
|
if ( every ) {
|
||||||
|
@ -67,7 +67,7 @@ public class SQLServerEveryAnyEmulation extends AbstractSqmSelfRenderingFunction
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(
|
public void render(
|
||||||
SqlAppender sqlAppender, List<SqlAstNode> sqlAstArguments, SqlAstTranslator<?> walker) {
|
SqlAppender sqlAppender, List<? extends SqlAstNode> sqlAstArguments, SqlAstTranslator<?> walker) {
|
||||||
this.render( sqlAppender, sqlAstArguments, null, walker );
|
this.render( sqlAppender, sqlAstArguments, null, walker );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,8 @@ import java.util.List;
|
||||||
import jakarta.persistence.TemporalType;
|
import jakarta.persistence.TemporalType;
|
||||||
|
|
||||||
import org.hibernate.dialect.SQLServerDialect;
|
import org.hibernate.dialect.SQLServerDialect;
|
||||||
import org.hibernate.query.spi.QueryEngine;
|
|
||||||
import org.hibernate.query.sqm.function.AbstractSqmSelfRenderingFunctionDescriptor;
|
import org.hibernate.query.sqm.function.AbstractSqmSelfRenderingFunctionDescriptor;
|
||||||
import org.hibernate.query.sqm.produce.function.ArgumentTypesValidator;
|
import org.hibernate.query.sqm.produce.function.ArgumentTypesValidator;
|
||||||
import org.hibernate.query.sqm.produce.function.FunctionParameterType;
|
|
||||||
import org.hibernate.query.sqm.produce.function.StandardArgumentsValidators;
|
import org.hibernate.query.sqm.produce.function.StandardArgumentsValidators;
|
||||||
import org.hibernate.query.sqm.produce.function.StandardFunctionReturnTypeResolvers;
|
import org.hibernate.query.sqm.produce.function.StandardFunctionReturnTypeResolvers;
|
||||||
import org.hibernate.sql.ast.SqlAstTranslator;
|
import org.hibernate.sql.ast.SqlAstTranslator;
|
||||||
|
@ -50,7 +48,7 @@ public class SQLServerFormatEmulation extends AbstractSqmSelfRenderingFunctionDe
|
||||||
@Override
|
@Override
|
||||||
public void render(
|
public void render(
|
||||||
SqlAppender sqlAppender,
|
SqlAppender sqlAppender,
|
||||||
List<SqlAstNode> arguments,
|
List<? extends SqlAstNode> arguments,
|
||||||
SqlAstTranslator<?> walker) {
|
SqlAstTranslator<?> walker) {
|
||||||
final Expression datetime = (Expression) arguments.get(0);
|
final Expression datetime = (Expression) arguments.get(0);
|
||||||
final boolean isTime = TypeConfiguration.getSqlTemporalType( datetime.getExpressionType() ) == TemporalType.TIME;
|
final boolean isTime = TypeConfiguration.getSqlTemporalType( datetime.getExpressionType() ) == TemporalType.TIME;
|
||||||
|
|
|
@ -15,7 +15,6 @@ import org.hibernate.sql.ast.SqlAstTranslator;
|
||||||
import org.hibernate.sql.ast.spi.SqlAppender;
|
import org.hibernate.sql.ast.spi.SqlAppender;
|
||||||
import org.hibernate.sql.ast.tree.SqlAstNode;
|
import org.hibernate.sql.ast.tree.SqlAstNode;
|
||||||
import org.hibernate.sql.ast.tree.expression.QueryLiteral;
|
import org.hibernate.sql.ast.tree.expression.QueryLiteral;
|
||||||
import org.hibernate.type.BasicType;
|
|
||||||
import org.hibernate.type.JavaObjectType;
|
import org.hibernate.type.JavaObjectType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,7 +36,7 @@ public class SqlFunction
|
||||||
@Override
|
@Override
|
||||||
public void render(
|
public void render(
|
||||||
SqlAppender sqlAppender,
|
SqlAppender sqlAppender,
|
||||||
List<SqlAstNode> arguments,
|
List<? extends SqlAstNode> arguments,
|
||||||
SqlAstTranslator<?> walker) {
|
SqlAstTranslator<?> walker) {
|
||||||
final QueryLiteral<String> sqlFragmentLiteral = (QueryLiteral<String>) arguments.get( 0 );
|
final QueryLiteral<String> sqlFragmentLiteral = (QueryLiteral<String>) arguments.get( 0 );
|
||||||
final String sqlFragment = sqlFragmentLiteral.getLiteralValue();
|
final String sqlFragment = sqlFragmentLiteral.getLiteralValue();
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class TimestampaddFunction
|
||||||
@Override
|
@Override
|
||||||
public void render(
|
public void render(
|
||||||
SqlAppender sqlAppender,
|
SqlAppender sqlAppender,
|
||||||
List<SqlAstNode> arguments,
|
List<? extends SqlAstNode> arguments,
|
||||||
SqlAstTranslator<?> walker) {
|
SqlAstTranslator<?> walker) {
|
||||||
|
|
||||||
final DurationUnit field = (DurationUnit) arguments.get( 0 );
|
final DurationUnit field = (DurationUnit) arguments.get( 0 );
|
||||||
|
@ -143,7 +143,7 @@ public class TimestampaddFunction
|
||||||
1,
|
1,
|
||||||
new SelfRenderingFunctionSqlAstExpression(
|
new SelfRenderingFunctionSqlAstExpression(
|
||||||
"cast",
|
"cast",
|
||||||
castFunction::render,
|
castFunction,
|
||||||
castArguments,
|
castArguments,
|
||||||
integerType,
|
integerType,
|
||||||
integerType
|
integerType
|
||||||
|
@ -190,7 +190,7 @@ public class TimestampaddFunction
|
||||||
Expression to = (Expression) sqlAstArguments[2];
|
Expression to = (Expression) sqlAstArguments[2];
|
||||||
return new SelfRenderingFunctionSqlAstExpression(
|
return new SelfRenderingFunctionSqlAstExpression(
|
||||||
getName(),
|
getName(),
|
||||||
this::render,
|
this,
|
||||||
asList( sqlAstArguments ),
|
asList( sqlAstArguments ),
|
||||||
impliedResultType != null
|
impliedResultType != null
|
||||||
? impliedResultType
|
? impliedResultType
|
||||||
|
|
|
@ -13,7 +13,6 @@ import org.hibernate.metamodel.model.domain.AllowableFunctionReturnType;
|
||||||
import org.hibernate.query.sqm.function.AbstractSqmSelfRenderingFunctionDescriptor;
|
import org.hibernate.query.sqm.function.AbstractSqmSelfRenderingFunctionDescriptor;
|
||||||
import org.hibernate.query.sqm.function.SelfRenderingFunctionSqlAstExpression;
|
import org.hibernate.query.sqm.function.SelfRenderingFunctionSqlAstExpression;
|
||||||
import org.hibernate.query.sqm.produce.function.ArgumentTypesValidator;
|
import org.hibernate.query.sqm.produce.function.ArgumentTypesValidator;
|
||||||
import org.hibernate.query.sqm.produce.function.FunctionParameterType;
|
|
||||||
import org.hibernate.query.sqm.produce.function.StandardArgumentsValidators;
|
import org.hibernate.query.sqm.produce.function.StandardArgumentsValidators;
|
||||||
import org.hibernate.query.sqm.produce.function.StandardFunctionReturnTypeResolvers;
|
import org.hibernate.query.sqm.produce.function.StandardFunctionReturnTypeResolvers;
|
||||||
import org.hibernate.query.sqm.produce.function.internal.PatternRenderer;
|
import org.hibernate.query.sqm.produce.function.internal.PatternRenderer;
|
||||||
|
@ -54,7 +53,7 @@ public class TimestampdiffFunction
|
||||||
@Override
|
@Override
|
||||||
public void render(
|
public void render(
|
||||||
SqlAppender sqlAppender,
|
SqlAppender sqlAppender,
|
||||||
List<SqlAstNode> arguments,
|
List<? extends SqlAstNode> arguments,
|
||||||
SqlAstTranslator<?> walker) {
|
SqlAstTranslator<?> walker) {
|
||||||
|
|
||||||
final DurationUnit field = (DurationUnit) arguments.get( 0 );
|
final DurationUnit field = (DurationUnit) arguments.get( 0 );
|
||||||
|
@ -104,7 +103,7 @@ public class TimestampdiffFunction
|
||||||
DurationUnit field = (DurationUnit) sqlAstArguments[0];
|
DurationUnit field = (DurationUnit) sqlAstArguments[0];
|
||||||
return new SelfRenderingFunctionSqlAstExpression(
|
return new SelfRenderingFunctionSqlAstExpression(
|
||||||
getName(),
|
getName(),
|
||||||
this::render,
|
this,
|
||||||
asList( sqlAstArguments ),
|
asList( sqlAstArguments ),
|
||||||
impliedResultType != null
|
impliedResultType != null
|
||||||
? impliedResultType
|
? impliedResultType
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class TransactSQLStrFunction extends CastStrEmulation implements Function
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(SqlAppender sqlAppender, List<SqlAstNode> arguments, SqlAstTranslator<?> walker) {
|
public void render(SqlAppender sqlAppender, List<? extends SqlAstNode> arguments, SqlAstTranslator<?> walker) {
|
||||||
sqlAppender.appendSql( "str(" );
|
sqlAppender.appendSql( "str(" );
|
||||||
arguments.get( 0 ).accept( walker );
|
arguments.get( 0 ).accept( walker );
|
||||||
for ( int i = 1; i < arguments.size(); i++ ) {
|
for ( int i = 1; i < arguments.size(); i++ ) {
|
||||||
|
|
|
@ -17,7 +17,7 @@ import org.hibernate.sql.ast.SqlAstTranslator;
|
||||||
import org.hibernate.sql.ast.spi.SqlAppender;
|
import org.hibernate.sql.ast.spi.SqlAppender;
|
||||||
import org.hibernate.sql.ast.tree.SqlAstNode;
|
import org.hibernate.sql.ast.tree.SqlAstNode;
|
||||||
import org.hibernate.sql.ast.tree.expression.Expression;
|
import org.hibernate.sql.ast.tree.expression.Expression;
|
||||||
import org.hibernate.sql.ast.tree.expression.QueryLiteral;
|
import org.hibernate.sql.ast.tree.expression.Literal;
|
||||||
import org.hibernate.sql.ast.tree.expression.TrimSpecification;
|
import org.hibernate.sql.ast.tree.expression.TrimSpecification;
|
||||||
import org.hibernate.type.StandardBasicTypes;
|
import org.hibernate.type.StandardBasicTypes;
|
||||||
import org.hibernate.type.spi.TypeConfiguration;
|
import org.hibernate.type.spi.TypeConfiguration;
|
||||||
|
@ -50,12 +50,12 @@ public class TrimFunction extends AbstractSqmSelfRenderingFunctionDescriptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(SqlAppender sqlAppender, List<SqlAstNode> sqlAstArguments, SqlAstTranslator<?> walker) {
|
public void render(SqlAppender sqlAppender, List<? extends SqlAstNode> sqlAstArguments, SqlAstTranslator<?> walker) {
|
||||||
final TrimSpec specification = ( (TrimSpecification) sqlAstArguments.get( 0 ) ).getSpecification();
|
final TrimSpec specification = ( (TrimSpecification) sqlAstArguments.get( 0 ) ).getSpecification();
|
||||||
final Character trimCharacter = ( (QueryLiteral<Character>) sqlAstArguments.get( 1 ) ).getLiteralValue();
|
final Object trimCharacter = ( (Literal) sqlAstArguments.get( 1 ) ).getLiteralValue();
|
||||||
final Expression sourceExpr = (Expression) sqlAstArguments.get( 2 );
|
final Expression sourceExpr = (Expression) sqlAstArguments.get( 2 );
|
||||||
|
|
||||||
String trim = dialect.trimPattern( specification, trimCharacter );
|
String trim = dialect.trimPattern( specification, (char) trimCharacter );
|
||||||
|
|
||||||
new PatternRenderer( trim ).render( sqlAppender, Collections.singletonList( sourceExpr ), walker );
|
new PatternRenderer( trim ).render( sqlAppender, Collections.singletonList( sourceExpr ), walker );
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,7 @@ public class FunctionExpression implements OrderingExpression, FunctionRendering
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(SqlAppender sqlAppender, List<SqlAstNode> sqlAstArguments, SqlAstTranslator<?> walker) {
|
public void render(SqlAppender sqlAppender, List<? extends SqlAstNode> sqlAstArguments, SqlAstTranslator<?> walker) {
|
||||||
sqlAppender.appendSql( name );
|
sqlAppender.appendSql( name );
|
||||||
sqlAppender.appendSql( '(' );
|
sqlAppender.appendSql( '(' );
|
||||||
if ( !sqlAstArguments.isEmpty() ) {
|
if ( !sqlAstArguments.isEmpty() ) {
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class ParameterMetadataImpl implements ParameterMetadataImplementor {
|
||||||
*/
|
*/
|
||||||
public static final ParameterMetadataImpl EMPTY = new ParameterMetadataImpl();
|
public static final ParameterMetadataImpl EMPTY = new ParameterMetadataImpl();
|
||||||
|
|
||||||
private final Map<QueryParameterImplementor<?>, List<SqmParameter>> queryParameters;
|
private final Map<QueryParameterImplementor<?>, List<SqmParameter<?>>> queryParameters;
|
||||||
|
|
||||||
private final Set<String> names;
|
private final Set<String> names;
|
||||||
private final Set<Integer> labels;
|
private final Set<Integer> labels;
|
||||||
|
@ -51,7 +51,7 @@ public class ParameterMetadataImpl implements ParameterMetadataImplementor {
|
||||||
this.labels = Collections.emptySet();
|
this.labels = Collections.emptySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ParameterMetadataImpl(Map<QueryParameterImplementor<?>, List<SqmParameter>> queryParameters) {
|
public ParameterMetadataImpl(Map<QueryParameterImplementor<?>, List<SqmParameter<?>>> queryParameters) {
|
||||||
this.queryParameters = queryParameters;
|
this.queryParameters = queryParameters;
|
||||||
|
|
||||||
// if we have any ordinal parameters, make sure the numbers
|
// if we have any ordinal parameters, make sure the numbers
|
||||||
|
@ -168,12 +168,12 @@ public class ParameterMetadataImpl implements ParameterMetadataImplementor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> AllowableParameterType<T> getInferredParameterType(QueryParameter<T> parameter) {
|
public <T> AllowableParameterType<T> getInferredParameterType(QueryParameter<T> parameter) {
|
||||||
final List<SqmParameter> sqmParameters = queryParameters.get( parameter );
|
final List<SqmParameter<?>> sqmParameters = queryParameters.get( parameter );
|
||||||
if ( sqmParameters == null || sqmParameters.isEmpty() ) {
|
if ( sqmParameters == null || sqmParameters.isEmpty() ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
for ( SqmParameter sqmParameter : sqmParameters ) {
|
for ( SqmParameter<?> sqmParameter : sqmParameters ) {
|
||||||
final AllowableParameterType nodeType = sqmParameter.getNodeType();
|
final AllowableParameterType<T> nodeType = (AllowableParameterType<T>) sqmParameter.getNodeType();
|
||||||
if ( nodeType != null ) {
|
if ( nodeType != null ) {
|
||||||
return nodeType;
|
return nodeType;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,10 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.query.internal;
|
package org.hibernate.query.internal;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import org.hibernate.metamodel.mapping.MappingModelExpressable;
|
|
||||||
import org.hibernate.query.spi.HqlInterpretation;
|
import org.hibernate.query.spi.HqlInterpretation;
|
||||||
import org.hibernate.query.spi.NonSelectQueryPlan;
|
import org.hibernate.query.spi.NonSelectQueryPlan;
|
||||||
import org.hibernate.query.spi.ParameterMetadataImplementor;
|
import org.hibernate.query.spi.ParameterMetadataImplementor;
|
||||||
|
@ -21,7 +18,6 @@ import org.hibernate.query.spi.SelectQueryPlan;
|
||||||
import org.hibernate.query.sql.spi.ParameterInterpretation;
|
import org.hibernate.query.sql.spi.ParameterInterpretation;
|
||||||
import org.hibernate.query.sqm.internal.DomainParameterXref;
|
import org.hibernate.query.sqm.internal.DomainParameterXref;
|
||||||
import org.hibernate.query.sqm.tree.SqmStatement;
|
import org.hibernate.query.sqm.tree.SqmStatement;
|
||||||
import org.hibernate.query.sqm.tree.expression.SqmParameter;
|
|
||||||
import org.hibernate.stat.spi.StatisticsImplementor;
|
import org.hibernate.stat.spi.StatisticsImplementor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,7 +86,7 @@ public class QueryInterpretationCacheDisabledImpl implements QueryInterpretation
|
||||||
|
|
||||||
return new HqlInterpretation() {
|
return new HqlInterpretation() {
|
||||||
@Override
|
@Override
|
||||||
public SqmStatement getSqmStatement() {
|
public SqmStatement<?> getSqmStatement() {
|
||||||
return sqmStatement;
|
return sqmStatement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -194,11 +194,11 @@ public class QueryInterpretationCacheStandardImpl implements QueryInterpretation
|
||||||
|
|
||||||
private static class ImmutableHqlInterpretation {
|
private static class ImmutableHqlInterpretation {
|
||||||
|
|
||||||
private final SqmStatement sqmStatement;
|
private final SqmStatement<?> sqmStatement;
|
||||||
private final ParameterMetadataImplementor parameterMetadata;
|
private final ParameterMetadataImplementor parameterMetadata;
|
||||||
|
|
||||||
public ImmutableHqlInterpretation(
|
public ImmutableHqlInterpretation(
|
||||||
SqmStatement sqmStatement,
|
SqmStatement<?> sqmStatement,
|
||||||
ParameterMetadataImplementor parameterMetadata) {
|
ParameterMetadataImplementor parameterMetadata) {
|
||||||
this.sqmStatement = sqmStatement;
|
this.sqmStatement = sqmStatement;
|
||||||
this.parameterMetadata = parameterMetadata;
|
this.parameterMetadata = parameterMetadata;
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class QueryParameterNamedImpl<T> extends AbstractQueryParameter<T> {
|
||||||
*
|
*
|
||||||
* @return The parameter descriptor
|
* @return The parameter descriptor
|
||||||
*/
|
*/
|
||||||
public static <T> QueryParameterNamedImpl<T> fromSqm(SqmParameter parameter) {
|
public static <T> QueryParameterNamedImpl<T> fromSqm(SqmParameter<?> parameter) {
|
||||||
assert parameter.getName() != null;
|
assert parameter.getName() != null;
|
||||||
assert parameter.getPosition() == null;
|
assert parameter.getPosition() == null;
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ public class QueryParameterNamedImpl<T> extends AbstractQueryParameter<T> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NamedQueryMemento.ParameterMemento toMemento() {
|
public NamedQueryMemento.ParameterMemento toMemento() {
|
||||||
return session -> new QueryParameterNamedImpl( getName(), allowsMultiValuedBinding(), getHibernateType() );
|
return session -> new QueryParameterNamedImpl<>( getName(), allowsMultiValuedBinding(), getHibernateType() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -169,10 +169,7 @@ public interface QueryOptions {
|
||||||
default boolean hasLimit() {
|
default boolean hasLimit() {
|
||||||
final Limit limit = getLimit();
|
final Limit limit = getLimit();
|
||||||
if ( limit != null ) {
|
if ( limit != null ) {
|
||||||
if ( limit.getFirstRow() != null ) {
|
if ( limit.getFirstRow() != null || limit.getMaxRows() != null ) {
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if ( limit.getMaxRows() != null ) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,12 +13,12 @@ import org.hibernate.query.sqm.tree.SqmStatement;
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class SimpleHqlInterpretationImpl implements HqlInterpretation {
|
public class SimpleHqlInterpretationImpl implements HqlInterpretation {
|
||||||
private final SqmStatement sqmStatement;
|
private final SqmStatement<?> sqmStatement;
|
||||||
private final ParameterMetadataImplementor parameterMetadata;
|
private final ParameterMetadataImplementor parameterMetadata;
|
||||||
private final DomainParameterXref domainParameterXref;
|
private final DomainParameterXref domainParameterXref;
|
||||||
|
|
||||||
public SimpleHqlInterpretationImpl(
|
public SimpleHqlInterpretationImpl(
|
||||||
SqmStatement sqmStatement,
|
SqmStatement<?> sqmStatement,
|
||||||
ParameterMetadataImplementor parameterMetadata,
|
ParameterMetadataImplementor parameterMetadata,
|
||||||
DomainParameterXref domainParameterXref) {
|
DomainParameterXref domainParameterXref) {
|
||||||
this.sqmStatement = sqmStatement;
|
this.sqmStatement = sqmStatement;
|
||||||
|
@ -27,7 +27,7 @@ public class SimpleHqlInterpretationImpl implements HqlInterpretation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SqmStatement getSqmStatement() {
|
public SqmStatement<?> getSqmStatement() {
|
||||||
return sqmStatement;
|
return sqmStatement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ public abstract class AbstractSqmSelfRenderingFunctionDescriptor
|
||||||
}
|
}
|
||||||
return new SelfRenderingSqmFunction<>(
|
return new SelfRenderingSqmFunction<>(
|
||||||
this,
|
this,
|
||||||
this::render,
|
(sqlAppender, sqlAstArguments, walker) -> render(sqlAppender, sqlAstArguments, walker),
|
||||||
arguments,
|
arguments,
|
||||||
impliedResultType,
|
impliedResultType,
|
||||||
getArgumentsValidator(),
|
getArgumentsValidator(),
|
||||||
|
@ -99,12 +99,12 @@ public abstract class AbstractSqmSelfRenderingFunctionDescriptor
|
||||||
*/
|
*/
|
||||||
public abstract void render(
|
public abstract void render(
|
||||||
SqlAppender sqlAppender,
|
SqlAppender sqlAppender,
|
||||||
List<SqlAstNode> sqlAstArguments,
|
List<? extends SqlAstNode> sqlAstArguments,
|
||||||
SqlAstTranslator<?> walker);
|
SqlAstTranslator<?> walker);
|
||||||
|
|
||||||
public void render(
|
public void render(
|
||||||
SqlAppender sqlAppender,
|
SqlAppender sqlAppender,
|
||||||
List<SqlAstNode> sqlAstArguments,
|
List<? extends SqlAstNode> sqlAstArguments,
|
||||||
Predicate filter,
|
Predicate filter,
|
||||||
SqlAstTranslator<?> walker) {
|
SqlAstTranslator<?> walker) {
|
||||||
render( sqlAppender, sqlAstArguments, walker );
|
render( sqlAppender, sqlAstArguments, walker );
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
package org.hibernate.query.sqm.function;
|
package org.hibernate.query.sqm.function;
|
||||||
|
|
||||||
import org.hibernate.sql.ast.SqlAstTranslator;
|
import org.hibernate.sql.ast.SqlAstTranslator;
|
||||||
import org.hibernate.sql.ast.SqlAstWalker;
|
|
||||||
import org.hibernate.sql.ast.spi.SqlAppender;
|
import org.hibernate.sql.ast.spi.SqlAppender;
|
||||||
import org.hibernate.sql.ast.tree.SqlAstNode;
|
import org.hibernate.sql.ast.tree.SqlAstNode;
|
||||||
import org.hibernate.sql.ast.tree.predicate.Predicate;
|
import org.hibernate.sql.ast.tree.predicate.Predicate;
|
||||||
|
@ -28,12 +27,12 @@ import java.util.List;
|
||||||
public interface FunctionRenderingSupport {
|
public interface FunctionRenderingSupport {
|
||||||
void render(
|
void render(
|
||||||
SqlAppender sqlAppender,
|
SqlAppender sqlAppender,
|
||||||
List<SqlAstNode> sqlAstArguments,
|
List<? extends SqlAstNode> sqlAstArguments,
|
||||||
SqlAstTranslator<?> walker);
|
SqlAstTranslator<?> walker);
|
||||||
|
|
||||||
default void render(
|
default void render(
|
||||||
SqlAppender sqlAppender,
|
SqlAppender sqlAppender,
|
||||||
List<SqlAstNode> sqlAstArguments,
|
List<? extends SqlAstNode> sqlAstArguments,
|
||||||
Predicate filter,
|
Predicate filter,
|
||||||
SqlAstTranslator<?> walker) {
|
SqlAstTranslator<?> walker) {
|
||||||
// Ignore the filter by default. Subclasses will override this
|
// Ignore the filter by default. Subclasses will override this
|
||||||
|
|
|
@ -91,7 +91,7 @@ public class NamedSqmFunctionDescriptor
|
||||||
@Override
|
@Override
|
||||||
public void render(
|
public void render(
|
||||||
SqlAppender sqlAppender,
|
SqlAppender sqlAppender,
|
||||||
List<SqlAstNode> sqlAstArguments,
|
List<? extends SqlAstNode> sqlAstArguments,
|
||||||
SqlAstTranslator<?> translator) {
|
SqlAstTranslator<?> translator) {
|
||||||
render( sqlAppender, sqlAstArguments, null, translator );
|
render( sqlAppender, sqlAstArguments, null, translator );
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ public class NamedSqmFunctionDescriptor
|
||||||
@Override
|
@Override
|
||||||
public void render(
|
public void render(
|
||||||
SqlAppender sqlAppender,
|
SqlAppender sqlAppender,
|
||||||
List<SqlAstNode> sqlAstArguments,
|
List<? extends SqlAstNode> sqlAstArguments,
|
||||||
Predicate filter,
|
Predicate filter,
|
||||||
SqlAstTranslator<?> translator) {
|
SqlAstTranslator<?> translator) {
|
||||||
final boolean useParens = useParenthesesWhenNoArgs || !sqlAstArguments.isEmpty();
|
final boolean useParens = useParenthesesWhenNoArgs || !sqlAstArguments.isEmpty();
|
||||||
|
|
|
@ -71,13 +71,13 @@ public class PatternBasedSqmFunctionDescriptor
|
||||||
@Override
|
@Override
|
||||||
public void render(
|
public void render(
|
||||||
SqlAppender sqlAppender,
|
SqlAppender sqlAppender,
|
||||||
List<SqlAstNode> sqlAstArguments,
|
List<? extends SqlAstNode> sqlAstArguments,
|
||||||
SqlAstTranslator<?> walker) {
|
SqlAstTranslator<?> walker) {
|
||||||
renderer.render( sqlAppender, sqlAstArguments, null, walker );
|
renderer.render( sqlAppender, sqlAstArguments, null, walker );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(SqlAppender sqlAppender, List<SqlAstNode> sqlAstArguments, Predicate filter, SqlAstTranslator<?> walker) {
|
public void render(SqlAppender sqlAppender, List<? extends SqlAstNode> sqlAstArguments, Predicate filter, SqlAstTranslator<?> walker) {
|
||||||
renderer.render( sqlAppender, sqlAstArguments, filter, walker );
|
renderer.render( sqlAppender, sqlAstArguments, filter, walker );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class SelfRenderingAggregateFunctionSqlAstExpression extends SelfRenderin
|
||||||
public SelfRenderingAggregateFunctionSqlAstExpression(
|
public SelfRenderingAggregateFunctionSqlAstExpression(
|
||||||
String functionName,
|
String functionName,
|
||||||
FunctionRenderingSupport renderer,
|
FunctionRenderingSupport renderer,
|
||||||
List<SqlAstNode> sqlAstArguments,
|
List<? extends SqlAstNode> sqlAstArguments,
|
||||||
Predicate filter,
|
Predicate filter,
|
||||||
AllowableFunctionReturnType<?> type,
|
AllowableFunctionReturnType<?> type,
|
||||||
JdbcMappingContainer expressable) {
|
JdbcMappingContainer expressable) {
|
||||||
|
|
|
@ -47,14 +47,14 @@ public class SelfRenderingFunctionSqlAstExpression
|
||||||
implements SelfRenderingExpression, Selectable, SqlExpressable, DomainResultProducer, FunctionExpression {
|
implements SelfRenderingExpression, Selectable, SqlExpressable, DomainResultProducer, FunctionExpression {
|
||||||
private final String functionName;
|
private final String functionName;
|
||||||
private final FunctionRenderingSupport renderer;
|
private final FunctionRenderingSupport renderer;
|
||||||
private final List<SqlAstNode> sqlAstArguments;
|
private final List<? extends SqlAstNode> sqlAstArguments;
|
||||||
private final AllowableFunctionReturnType<?> type;
|
private final AllowableFunctionReturnType<?> type;
|
||||||
private final JdbcMappingContainer expressable;
|
private final JdbcMappingContainer expressable;
|
||||||
|
|
||||||
public SelfRenderingFunctionSqlAstExpression(
|
public SelfRenderingFunctionSqlAstExpression(
|
||||||
String functionName,
|
String functionName,
|
||||||
FunctionRenderingSupport renderer,
|
FunctionRenderingSupport renderer,
|
||||||
List<SqlAstNode> sqlAstArguments,
|
List<? extends SqlAstNode> sqlAstArguments,
|
||||||
AllowableFunctionReturnType<?> type,
|
AllowableFunctionReturnType<?> type,
|
||||||
JdbcMappingContainer expressable) {
|
JdbcMappingContainer expressable) {
|
||||||
this.functionName = functionName;
|
this.functionName = functionName;
|
||||||
|
@ -71,7 +71,7 @@ public class SelfRenderingFunctionSqlAstExpression
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SqlAstNode> getArguments() {
|
public List<? extends SqlAstNode> getArguments() {
|
||||||
return sqlAstArguments;
|
return sqlAstArguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.hibernate.query.spi.QueryOptions;
|
||||||
import org.hibernate.query.spi.QueryParameterImplementor;
|
import org.hibernate.query.spi.QueryParameterImplementor;
|
||||||
import org.hibernate.query.spi.ScrollableResultsImplementor;
|
import org.hibernate.query.spi.ScrollableResultsImplementor;
|
||||||
import org.hibernate.query.spi.SelectQueryPlan;
|
import org.hibernate.query.spi.SelectQueryPlan;
|
||||||
|
import org.hibernate.query.sqm.spi.SqmParameterMappingModelResolutionAccess;
|
||||||
import org.hibernate.query.sqm.sql.SqmTranslation;
|
import org.hibernate.query.sqm.sql.SqmTranslation;
|
||||||
import org.hibernate.query.sqm.sql.SqmTranslator;
|
import org.hibernate.query.sqm.sql.SqmTranslator;
|
||||||
import org.hibernate.query.sqm.sql.SqmTranslatorFactory;
|
import org.hibernate.query.sqm.sql.SqmTranslatorFactory;
|
||||||
|
@ -68,7 +69,7 @@ import static org.hibernate.query.sqm.internal.QuerySqmImpl.CRITERIA_HQL_STRING;
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class ConcreteSqmSelectQueryPlan<R> implements SelectQueryPlan<R> {
|
public class ConcreteSqmSelectQueryPlan<R> implements SelectQueryPlan<R> {
|
||||||
private final SqmSelectStatement sqm;
|
private final SqmSelectStatement<?> sqm;
|
||||||
private final String hql;
|
private final String hql;
|
||||||
private final DomainParameterXref domainParameterXref;
|
private final DomainParameterXref domainParameterXref;
|
||||||
private final RowTransformer<R> rowTransformer;
|
private final RowTransformer<R> rowTransformer;
|
||||||
|
@ -79,7 +80,7 @@ public class ConcreteSqmSelectQueryPlan<R> implements SelectQueryPlan<R> {
|
||||||
|
|
||||||
@SuppressWarnings("WeakerAccess")
|
@SuppressWarnings("WeakerAccess")
|
||||||
public ConcreteSqmSelectQueryPlan(
|
public ConcreteSqmSelectQueryPlan(
|
||||||
SqmSelectStatement sqm,
|
SqmSelectStatement<?> sqm,
|
||||||
String hql,
|
String hql,
|
||||||
DomainParameterXref domainParameterXref,
|
DomainParameterXref domainParameterXref,
|
||||||
Class<R> resultType,
|
Class<R> resultType,
|
||||||
|
@ -136,26 +137,24 @@ public class ConcreteSqmSelectQueryPlan<R> implements SelectQueryPlan<R> {
|
||||||
|
|
||||||
this.scrollInterpreter = (scrollMode, executionContext, sqmInterpretation, jdbcParameterBindings) -> {
|
this.scrollInterpreter = (scrollMode, executionContext, sqmInterpretation, jdbcParameterBindings) -> {
|
||||||
try {
|
try {
|
||||||
final SubselectFetch.RegistrationHandler subSelectFetchKeyHandler = SubselectFetch.createRegistrationHandler(
|
// final SubselectFetch.RegistrationHandler subSelectFetchKeyHandler = SubselectFetch.createRegistrationHandler(
|
||||||
executionContext.getSession().getPersistenceContext().getBatchFetchQueue(),
|
// executionContext.getSession().getPersistenceContext().getBatchFetchQueue(),
|
||||||
sqmInterpretation.selectStatement,
|
// sqmInterpretation.selectStatement,
|
||||||
Collections.emptyList(),
|
// Collections.emptyList(),
|
||||||
jdbcParameterBindings
|
// jdbcParameterBindings
|
||||||
);
|
// );
|
||||||
|
|
||||||
final JdbcSelectExecutor jdbcSelectExecutor = executionContext.getSession()
|
final JdbcSelectExecutor jdbcSelectExecutor = executionContext.getSession()
|
||||||
.getFactory()
|
.getFactory()
|
||||||
.getJdbcServices()
|
.getJdbcServices()
|
||||||
.getJdbcSelectExecutor();
|
.getJdbcSelectExecutor();
|
||||||
final ScrollableResultsImplementor<R> result = jdbcSelectExecutor.scroll(
|
return jdbcSelectExecutor.scroll(
|
||||||
sqmInterpretation.getJdbcSelect(),
|
sqmInterpretation.getJdbcSelect(),
|
||||||
scrollMode,
|
scrollMode,
|
||||||
jdbcParameterBindings,
|
jdbcParameterBindings,
|
||||||
new SqmJdbcExecutionContextAdapter( executionContext, sqmInterpretation.jdbcSelect ),
|
new SqmJdbcExecutionContextAdapter( executionContext, sqmInterpretation.jdbcSelect ),
|
||||||
rowTransformer
|
rowTransformer
|
||||||
);
|
);
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
domainParameterXref.clearExpansions();
|
domainParameterXref.clearExpansions();
|
||||||
|
@ -176,7 +175,7 @@ public class ConcreteSqmSelectQueryPlan<R> implements SelectQueryPlan<R> {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private RowTransformer<R> determineRowTransformer(
|
private RowTransformer<R> determineRowTransformer(
|
||||||
SqmSelectStatement sqm,
|
SqmSelectStatement<?> sqm,
|
||||||
Class<R> resultType,
|
Class<R> resultType,
|
||||||
QueryOptions queryOptions) {
|
QueryOptions queryOptions) {
|
||||||
if ( resultType == null || resultType.isArray() ) {
|
if ( resultType == null || resultType.isArray() ) {
|
||||||
|
@ -237,7 +236,7 @@ public class ConcreteSqmSelectQueryPlan<R> implements SelectQueryPlan<R> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private RowTransformer<R> makeRowTransformerTupleTransformerAdapter(
|
private RowTransformer<R> makeRowTransformerTupleTransformerAdapter(
|
||||||
SqmSelectStatement sqm,
|
SqmSelectStatement<?> sqm,
|
||||||
QueryOptions queryOptions) {
|
QueryOptions queryOptions) {
|
||||||
final List<String> aliases = new ArrayList<>();
|
final List<String> aliases = new ArrayList<>();
|
||||||
for ( SqmSelection<?> sqmSelection : sqm.getQuerySpec().getSelectClause().getSelections() ) {
|
for ( SqmSelection<?> sqmSelection : sqm.getQuerySpec().getSelectClause().getSelections() ) {
|
||||||
|
@ -252,8 +251,9 @@ public class ConcreteSqmSelectQueryPlan<R> implements SelectQueryPlan<R> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new RowTransformerTupleTransformerAdapter<>(
|
return new RowTransformerTupleTransformerAdapter<R>(
|
||||||
ArrayHelper.toStringArray( aliases ), queryOptions.getTupleTransformer()
|
ArrayHelper.toStringArray( aliases ),
|
||||||
|
queryOptions.getTupleTransformer()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,7 +332,13 @@ public class ConcreteSqmSelectQueryPlan<R> implements SelectQueryPlan<R> {
|
||||||
sqmInterpretation.getJdbcParamsXref(),
|
sqmInterpretation.getJdbcParamsXref(),
|
||||||
session.getFactory().getDomainModel(),
|
session.getFactory().getDomainModel(),
|
||||||
sqmInterpretation.getTableGroupAccess()::findTableGroup,
|
sqmInterpretation.getTableGroupAccess()::findTableGroup,
|
||||||
sqmInterpretation.getSqmParameterMappingModelTypes()::get,
|
new SqmParameterMappingModelResolutionAccess() {
|
||||||
|
//this is pretty ugly!
|
||||||
|
@Override @SuppressWarnings("unchecked")
|
||||||
|
public <T> MappingModelExpressable<T> getResolvedMappingModelType(SqmParameter<T> parameter) {
|
||||||
|
return (MappingModelExpressable<T>) sqmInterpretation.getSqmParameterMappingModelTypes().get(parameter);
|
||||||
|
}
|
||||||
|
},
|
||||||
session
|
session
|
||||||
);
|
);
|
||||||
sqmInterpretation.getJdbcSelect().bindFilterJdbcParameters( jdbcParameterBindings );
|
sqmInterpretation.getJdbcSelect().bindFilterJdbcParameters( jdbcParameterBindings );
|
||||||
|
@ -340,7 +346,7 @@ public class ConcreteSqmSelectQueryPlan<R> implements SelectQueryPlan<R> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static CacheableSqmInterpretation buildCacheableSqmInterpretation(
|
private static CacheableSqmInterpretation buildCacheableSqmInterpretation(
|
||||||
SqmSelectStatement sqm,
|
SqmSelectStatement<?> sqm,
|
||||||
DomainParameterXref domainParameterXref,
|
DomainParameterXref domainParameterXref,
|
||||||
DomainQueryExecutionContext executionContext) {
|
DomainQueryExecutionContext executionContext) {
|
||||||
final SharedSessionContractImplementor session = executionContext.getSession();
|
final SharedSessionContractImplementor session = executionContext.getSession();
|
||||||
|
@ -370,17 +376,20 @@ public class ConcreteSqmSelectQueryPlan<R> implements SelectQueryPlan<R> {
|
||||||
sqmInterpretation.getSqlAst()
|
sqmInterpretation.getSqlAst()
|
||||||
);
|
);
|
||||||
|
|
||||||
final Map<QueryParameterImplementor<?>, Map<SqmParameter, List<List<JdbcParameter>>>> jdbcParamsXref = SqmUtil.generateJdbcParamsXref(
|
final Map<QueryParameterImplementor<?>, Map<SqmParameter<?>, List<List<JdbcParameter>>>> jdbcParamsXref
|
||||||
domainParameterXref,
|
= SqmUtil.generateJdbcParamsXref( domainParameterXref, sqmInterpretation::getJdbcParamsBySqmParam );
|
||||||
sqmInterpretation::getJdbcParamsBySqmParam
|
|
||||||
);
|
|
||||||
final JdbcParameterBindings jdbcParameterBindings = SqmUtil.createJdbcParameterBindings(
|
final JdbcParameterBindings jdbcParameterBindings = SqmUtil.createJdbcParameterBindings(
|
||||||
executionContext.getQueryParameterBindings(),
|
executionContext.getQueryParameterBindings(),
|
||||||
domainParameterXref,
|
domainParameterXref,
|
||||||
jdbcParamsXref,
|
jdbcParamsXref,
|
||||||
session.getFactory().getDomainModel(),
|
session.getFactory().getDomainModel(),
|
||||||
tableGroupAccess::findTableGroup,
|
tableGroupAccess::findTableGroup,
|
||||||
sqmInterpretation.getSqmParameterMappingModelTypeResolutions()::get,
|
new SqmParameterMappingModelResolutionAccess() {
|
||||||
|
@Override @SuppressWarnings("unchecked")
|
||||||
|
public <T> MappingModelExpressable<T> getResolvedMappingModelType(SqmParameter<T> parameter) {
|
||||||
|
return (MappingModelExpressable<T>) sqmInterpretation.getSqmParameterMappingModelTypeResolutions().get(parameter);
|
||||||
|
}
|
||||||
|
},
|
||||||
session
|
session
|
||||||
);
|
);
|
||||||
final JdbcSelect jdbcSelect = selectTranslator.translate( jdbcParameterBindings, executionContext.getQueryOptions() );
|
final JdbcSelect jdbcSelect = selectTranslator.translate( jdbcParameterBindings, executionContext.getQueryOptions() );
|
||||||
|
@ -407,16 +416,16 @@ public class ConcreteSqmSelectQueryPlan<R> implements SelectQueryPlan<R> {
|
||||||
private final SelectStatement selectStatement;
|
private final SelectStatement selectStatement;
|
||||||
private final JdbcSelect jdbcSelect;
|
private final JdbcSelect jdbcSelect;
|
||||||
private final FromClauseAccess tableGroupAccess;
|
private final FromClauseAccess tableGroupAccess;
|
||||||
private final Map<QueryParameterImplementor<?>, Map<SqmParameter, List<List<JdbcParameter>>>> jdbcParamsXref;
|
private final Map<QueryParameterImplementor<?>, Map<SqmParameter<?>, List<List<JdbcParameter>>>> jdbcParamsXref;
|
||||||
private final Map<SqmParameter, MappingModelExpressable> sqmParameterMappingModelTypes;
|
private final Map<SqmParameter<?>, MappingModelExpressable<?>> sqmParameterMappingModelTypes;
|
||||||
private transient JdbcParameterBindings firstParameterBindings;
|
private transient JdbcParameterBindings firstParameterBindings;
|
||||||
|
|
||||||
CacheableSqmInterpretation(
|
CacheableSqmInterpretation(
|
||||||
SelectStatement selectStatement,
|
SelectStatement selectStatement,
|
||||||
JdbcSelect jdbcSelect,
|
JdbcSelect jdbcSelect,
|
||||||
FromClauseAccess tableGroupAccess,
|
FromClauseAccess tableGroupAccess,
|
||||||
Map<QueryParameterImplementor<?>, Map<SqmParameter, List<List<JdbcParameter>>>> jdbcParamsXref,
|
Map<QueryParameterImplementor<?>, Map<SqmParameter<?>, List<List<JdbcParameter>>>> jdbcParamsXref,
|
||||||
Map<SqmParameter,MappingModelExpressable> sqmParameterMappingModelTypes,
|
Map<SqmParameter<?>,MappingModelExpressable<?>> sqmParameterMappingModelTypes,
|
||||||
JdbcParameterBindings firstParameterBindings) {
|
JdbcParameterBindings firstParameterBindings) {
|
||||||
this.selectStatement = selectStatement;
|
this.selectStatement = selectStatement;
|
||||||
this.jdbcSelect = jdbcSelect;
|
this.jdbcSelect = jdbcSelect;
|
||||||
|
@ -438,11 +447,11 @@ public class ConcreteSqmSelectQueryPlan<R> implements SelectQueryPlan<R> {
|
||||||
return tableGroupAccess;
|
return tableGroupAccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<QueryParameterImplementor<?>, Map<SqmParameter, List<List<JdbcParameter>>>> getJdbcParamsXref() {
|
Map<QueryParameterImplementor<?>, Map<SqmParameter<?>, List<List<JdbcParameter>>>> getJdbcParamsXref() {
|
||||||
return jdbcParamsXref;
|
return jdbcParamsXref;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<SqmParameter, MappingModelExpressable> getSqmParameterMappingModelTypes() {
|
public Map<SqmParameter<?>, MappingModelExpressable<?>> getSqmParameterMappingModelTypes() {
|
||||||
return sqmParameterMappingModelTypes;
|
return sqmParameterMappingModelTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,10 +82,10 @@ public class DomainParameterXref {
|
||||||
return empty();
|
return empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
final Map<QueryParameterImplementor<?>, List<SqmParameter>> sqmParamsByQueryParam = new IdentityHashMap<>();
|
final Map<QueryParameterImplementor<?>, List<SqmParameter<?>>> sqmParamsByQueryParam = new IdentityHashMap<>();
|
||||||
|
|
||||||
final int sqmParamCount = parameterResolutions.getSqmParameters().size();
|
final int sqmParamCount = parameterResolutions.getSqmParameters().size();
|
||||||
final Map<SqmParameter, QueryParameterImplementor<?>> queryParamBySqmParam = new IdentityHashMap<>( sqmParamCount );
|
final Map<SqmParameter<?>, QueryParameterImplementor<?>> queryParamBySqmParam = new IdentityHashMap<>( sqmParamCount );
|
||||||
|
|
||||||
for ( SqmParameter<?> sqmParameter : parameterResolutions.getSqmParameters() ) {
|
for ( SqmParameter<?> sqmParameter : parameterResolutions.getSqmParameters() ) {
|
||||||
if ( sqmParameter instanceof JpaCriteriaParameter ) {
|
if ( sqmParameter instanceof JpaCriteriaParameter ) {
|
||||||
|
@ -147,17 +147,17 @@ public class DomainParameterXref {
|
||||||
|
|
||||||
private final SqmStatement.ParameterResolutions parameterResolutions;
|
private final SqmStatement.ParameterResolutions parameterResolutions;
|
||||||
|
|
||||||
private final Map<QueryParameterImplementor<?>, List<SqmParameter>> sqmParamsByQueryParam;
|
private final Map<QueryParameterImplementor<?>, List<SqmParameter<?>>> sqmParamsByQueryParam;
|
||||||
private final Map<SqmParameter, QueryParameterImplementor<?>> queryParamBySqmParam;
|
private final Map<SqmParameter<?>, QueryParameterImplementor<?>> queryParamBySqmParam;
|
||||||
|
|
||||||
private Map<SqmParameter,List<SqmParameter>> expansions;
|
private Map<SqmParameter<?>,List<SqmParameter<?>>> expansions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @implSpec Constructor is defined as public for
|
* @implSpec Constructor is defined as public for
|
||||||
*/
|
*/
|
||||||
public DomainParameterXref(
|
public DomainParameterXref(
|
||||||
Map<QueryParameterImplementor<?>, List<SqmParameter>> sqmParamsByQueryParam,
|
Map<QueryParameterImplementor<?>, List<SqmParameter<?>>> sqmParamsByQueryParam,
|
||||||
Map<SqmParameter, QueryParameterImplementor<?>> queryParamBySqmParam,
|
Map<SqmParameter<?>, QueryParameterImplementor<?>> queryParamBySqmParam,
|
||||||
SqmStatement.ParameterResolutions parameterResolutions) {
|
SqmStatement.ParameterResolutions parameterResolutions) {
|
||||||
this.sqmParamsByQueryParam = sqmParamsByQueryParam;
|
this.sqmParamsByQueryParam = sqmParamsByQueryParam;
|
||||||
this.queryParamBySqmParam = queryParamBySqmParam;
|
this.queryParamBySqmParam = queryParamBySqmParam;
|
||||||
|
@ -174,7 +174,7 @@ public class DomainParameterXref {
|
||||||
/**
|
/**
|
||||||
* Get all of the QueryParameters mapped by this xref
|
* Get all of the QueryParameters mapped by this xref
|
||||||
*/
|
*/
|
||||||
public Map<QueryParameterImplementor<?>, List<SqmParameter>> getQueryParameters() {
|
public Map<QueryParameterImplementor<?>, List<SqmParameter<?>>> getQueryParameters() {
|
||||||
return sqmParamsByQueryParam;
|
return sqmParamsByQueryParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ public class DomainParameterXref {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getNumberOfSqmParameters(QueryParameterImplementor<?> queryParameter) {
|
public int getNumberOfSqmParameters(QueryParameterImplementor<?> queryParameter) {
|
||||||
final List<SqmParameter> sqmParameters = sqmParamsByQueryParam.get( queryParameter );
|
final List<SqmParameter<?>> sqmParameters = sqmParamsByQueryParam.get( queryParameter );
|
||||||
if ( sqmParameters == null ) {
|
if ( sqmParameters == null ) {
|
||||||
// this should maybe be an exception instead
|
// this should maybe be an exception instead
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -199,7 +199,7 @@ public class DomainParameterXref {
|
||||||
* Get the mapping of all QueryParameters to the List of its corresponding
|
* Get the mapping of all QueryParameters to the List of its corresponding
|
||||||
* SqmParameters
|
* SqmParameters
|
||||||
*/
|
*/
|
||||||
public Map<QueryParameterImplementor<?>, List<SqmParameter>> getSqmParamByQueryParam() {
|
public Map<QueryParameterImplementor<?>, List<SqmParameter<?>>> getSqmParamByQueryParam() {
|
||||||
return sqmParamsByQueryParam;
|
return sqmParamsByQueryParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,13 +207,13 @@ public class DomainParameterXref {
|
||||||
return parameterResolutions;
|
return parameterResolutions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SqmParameter> getSqmParameters(QueryParameterImplementor<?> queryParameter) {
|
public List<SqmParameter<?>> getSqmParameters(QueryParameterImplementor<?> queryParameter) {
|
||||||
return sqmParamsByQueryParam.get( queryParameter );
|
return sqmParamsByQueryParam.get( queryParameter );
|
||||||
}
|
}
|
||||||
|
|
||||||
public QueryParameterImplementor<?> getQueryParameter(SqmParameter sqmParameter) {
|
public QueryParameterImplementor<?> getQueryParameter(SqmParameter<?> sqmParameter) {
|
||||||
if ( sqmParameter instanceof SqmJpaCriteriaParameterWrapper ) {
|
if ( sqmParameter instanceof SqmJpaCriteriaParameterWrapper ) {
|
||||||
return ( (SqmJpaCriteriaParameterWrapper) sqmParameter ).getJpaCriteriaParameter();
|
return ( (SqmJpaCriteriaParameterWrapper<?>) sqmParameter ).getJpaCriteriaParameter();
|
||||||
}
|
}
|
||||||
else if ( sqmParameter instanceof QueryParameterImplementor<?> ) {
|
else if ( sqmParameter instanceof QueryParameterImplementor<?> ) {
|
||||||
return (QueryParameterImplementor<?>) sqmParameter;
|
return (QueryParameterImplementor<?>) sqmParameter;
|
||||||
|
@ -235,12 +235,12 @@ public class DomainParameterXref {
|
||||||
expansions.computeIfAbsent( originalSqmParameter, p -> new ArrayList<>() ).add( expansion );
|
expansions.computeIfAbsent( originalSqmParameter, p -> new ArrayList<>() ).add( expansion );
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SqmParameter> getExpansions(SqmParameter sqmParameter) {
|
public List<SqmParameter<?>> getExpansions(SqmParameter<?> sqmParameter) {
|
||||||
if ( expansions == null ) {
|
if ( expansions == null ) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<SqmParameter> sqmParameters = expansions.get( sqmParameter );
|
final List<SqmParameter<?>> sqmParameters = expansions.get( sqmParameter );
|
||||||
return sqmParameters == null ? Collections.emptyList() : sqmParameters;
|
return sqmParameters == null ? Collections.emptyList() : sqmParameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,8 +249,8 @@ public class DomainParameterXref {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( List<SqmParameter> expansionList : expansions.values() ) {
|
for ( List<SqmParameter<?>> expansionList : expansions.values() ) {
|
||||||
for ( SqmParameter expansion : expansionList ) {
|
for ( SqmParameter<?> expansion : expansionList ) {
|
||||||
queryParamBySqmParam.remove( expansion );
|
queryParamBySqmParam.remove( expansion );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.metamodel.mapping.EntityMappingType;
|
import org.hibernate.metamodel.mapping.EntityMappingType;
|
||||||
import org.hibernate.metamodel.mapping.ForeignKeyDescriptor;
|
import org.hibernate.metamodel.mapping.ForeignKeyDescriptor;
|
||||||
|
import org.hibernate.metamodel.mapping.MappingModelExpressable;
|
||||||
import org.hibernate.metamodel.mapping.MappingModelHelper;
|
import org.hibernate.metamodel.mapping.MappingModelHelper;
|
||||||
import org.hibernate.query.NavigablePath;
|
import org.hibernate.query.NavigablePath;
|
||||||
import org.hibernate.query.spi.DomainQueryExecutionContext;
|
import org.hibernate.query.spi.DomainQueryExecutionContext;
|
||||||
|
@ -22,6 +23,7 @@ import org.hibernate.query.spi.NonSelectQueryPlan;
|
||||||
import org.hibernate.query.spi.QueryEngine;
|
import org.hibernate.query.spi.QueryEngine;
|
||||||
import org.hibernate.query.spi.QueryParameterImplementor;
|
import org.hibernate.query.spi.QueryParameterImplementor;
|
||||||
import org.hibernate.query.sqm.mutation.internal.SqmMutationStrategyHelper;
|
import org.hibernate.query.sqm.mutation.internal.SqmMutationStrategyHelper;
|
||||||
|
import org.hibernate.query.sqm.spi.SqmParameterMappingModelResolutionAccess;
|
||||||
import org.hibernate.query.sqm.sql.SqmTranslation;
|
import org.hibernate.query.sqm.sql.SqmTranslation;
|
||||||
import org.hibernate.query.sqm.sql.SqmTranslator;
|
import org.hibernate.query.sqm.sql.SqmTranslator;
|
||||||
import org.hibernate.query.sqm.sql.SqmTranslatorFactory;
|
import org.hibernate.query.sqm.sql.SqmTranslatorFactory;
|
||||||
|
@ -43,16 +45,16 @@ import org.hibernate.sql.results.internal.SqlSelectionImpl;
|
||||||
*/
|
*/
|
||||||
public class SimpleDeleteQueryPlan implements NonSelectQueryPlan {
|
public class SimpleDeleteQueryPlan implements NonSelectQueryPlan {
|
||||||
private final EntityMappingType entityDescriptor;
|
private final EntityMappingType entityDescriptor;
|
||||||
private final SqmDeleteStatement sqmDelete;
|
private final SqmDeleteStatement<?> sqmDelete;
|
||||||
private final DomainParameterXref domainParameterXref;
|
private final DomainParameterXref domainParameterXref;
|
||||||
|
|
||||||
private JdbcDelete jdbcDelete;
|
private JdbcDelete jdbcDelete;
|
||||||
private SqmTranslation<DeleteStatement> sqmInterpretation;
|
private SqmTranslation<DeleteStatement> sqmInterpretation;
|
||||||
private Map<QueryParameterImplementor<?>, Map<SqmParameter, List<List<JdbcParameter>>>> jdbcParamsXref;
|
private Map<QueryParameterImplementor<?>, Map<SqmParameter<?>, List<List<JdbcParameter>>>> jdbcParamsXref;
|
||||||
|
|
||||||
public SimpleDeleteQueryPlan(
|
public SimpleDeleteQueryPlan(
|
||||||
EntityMappingType entityDescriptor,
|
EntityMappingType entityDescriptor,
|
||||||
SqmDeleteStatement sqmDelete,
|
SqmDeleteStatement<?> sqmDelete,
|
||||||
DomainParameterXref domainParameterXref) {
|
DomainParameterXref domainParameterXref) {
|
||||||
assert entityDescriptor.getEntityName().equals( sqmDelete.getTarget().getEntityName() );
|
assert entityDescriptor.getEntityName().equals( sqmDelete.getTarget().getEntityName() );
|
||||||
|
|
||||||
|
@ -103,7 +105,12 @@ public class SimpleDeleteQueryPlan implements NonSelectQueryPlan {
|
||||||
jdbcParamsXref,
|
jdbcParamsXref,
|
||||||
factory.getDomainModel(),
|
factory.getDomainModel(),
|
||||||
sqmInterpretation.getFromClauseAccess()::findTableGroup,
|
sqmInterpretation.getFromClauseAccess()::findTableGroup,
|
||||||
sqmInterpretation.getSqmParameterMappingModelTypeResolutions()::get,
|
new SqmParameterMappingModelResolutionAccess() {
|
||||||
|
@Override @SuppressWarnings("unchecked")
|
||||||
|
public <T> MappingModelExpressable<T> getResolvedMappingModelType(SqmParameter<T> parameter) {
|
||||||
|
return (MappingModelExpressable<T>) sqmInterpretation.getSqmParameterMappingModelTypeResolutions().get(parameter);
|
||||||
|
}
|
||||||
|
},
|
||||||
session
|
session
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ import org.hibernate.query.spi.DomainQueryExecutionContext;
|
||||||
import org.hibernate.query.spi.NonSelectQueryPlan;
|
import org.hibernate.query.spi.NonSelectQueryPlan;
|
||||||
import org.hibernate.query.spi.QueryEngine;
|
import org.hibernate.query.spi.QueryEngine;
|
||||||
import org.hibernate.query.spi.QueryParameterImplementor;
|
import org.hibernate.query.spi.QueryParameterImplementor;
|
||||||
|
import org.hibernate.query.sqm.spi.SqmParameterMappingModelResolutionAccess;
|
||||||
import org.hibernate.query.sqm.sql.SqmTranslation;
|
import org.hibernate.query.sqm.sql.SqmTranslation;
|
||||||
import org.hibernate.query.sqm.sql.SqmTranslator;
|
import org.hibernate.query.sqm.sql.SqmTranslator;
|
||||||
import org.hibernate.query.sqm.sql.SqmTranslatorFactory;
|
import org.hibernate.query.sqm.sql.SqmTranslatorFactory;
|
||||||
|
@ -34,16 +35,16 @@ import org.hibernate.sql.exec.spi.JdbcParameterBindings;
|
||||||
* @author Gavin King
|
* @author Gavin King
|
||||||
*/
|
*/
|
||||||
public class SimpleInsertQueryPlan implements NonSelectQueryPlan {
|
public class SimpleInsertQueryPlan implements NonSelectQueryPlan {
|
||||||
private final SqmInsertStatement sqmInsert;
|
private final SqmInsertStatement<?> sqmInsert;
|
||||||
private final DomainParameterXref domainParameterXref;
|
private final DomainParameterXref domainParameterXref;
|
||||||
private Map<SqmParameter, MappingModelExpressable> paramTypeResolutions;
|
private Map<SqmParameter<?>, MappingModelExpressable<?>> paramTypeResolutions;
|
||||||
|
|
||||||
private JdbcInsert jdbcInsert;
|
private JdbcInsert jdbcInsert;
|
||||||
private FromClauseAccess tableGroupAccess;
|
private FromClauseAccess tableGroupAccess;
|
||||||
private Map<QueryParameterImplementor<?>, Map<SqmParameter, List<List<JdbcParameter>>>> jdbcParamsXref;
|
private Map<QueryParameterImplementor<?>, Map<SqmParameter<?>, List<List<JdbcParameter>>>> jdbcParamsXref;
|
||||||
|
|
||||||
public SimpleInsertQueryPlan(
|
public SimpleInsertQueryPlan(
|
||||||
SqmInsertStatement sqmInsert,
|
SqmInsertStatement<?> sqmInsert,
|
||||||
DomainParameterXref domainParameterXref) {
|
DomainParameterXref domainParameterXref) {
|
||||||
this.sqmInsert = sqmInsert;
|
this.sqmInsert = sqmInsert;
|
||||||
this.domainParameterXref = domainParameterXref;
|
this.domainParameterXref = domainParameterXref;
|
||||||
|
@ -97,7 +98,12 @@ public class SimpleInsertQueryPlan implements NonSelectQueryPlan {
|
||||||
jdbcParamsXref,
|
jdbcParamsXref,
|
||||||
factory.getDomainModel(),
|
factory.getDomainModel(),
|
||||||
tableGroupAccess::findTableGroup,
|
tableGroupAccess::findTableGroup,
|
||||||
paramTypeResolutions::get,
|
new SqmParameterMappingModelResolutionAccess() {
|
||||||
|
@Override @SuppressWarnings("unchecked")
|
||||||
|
public <T> MappingModelExpressable<T> getResolvedMappingModelType(SqmParameter<T> parameter) {
|
||||||
|
return (MappingModelExpressable<T>) paramTypeResolutions.get(parameter);
|
||||||
|
}
|
||||||
|
},
|
||||||
session
|
session
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ import org.hibernate.query.spi.DomainQueryExecutionContext;
|
||||||
import org.hibernate.query.spi.NonSelectQueryPlan;
|
import org.hibernate.query.spi.NonSelectQueryPlan;
|
||||||
import org.hibernate.query.spi.QueryEngine;
|
import org.hibernate.query.spi.QueryEngine;
|
||||||
import org.hibernate.query.spi.QueryParameterImplementor;
|
import org.hibernate.query.spi.QueryParameterImplementor;
|
||||||
|
import org.hibernate.query.sqm.spi.SqmParameterMappingModelResolutionAccess;
|
||||||
import org.hibernate.query.sqm.sql.SqmTranslation;
|
import org.hibernate.query.sqm.sql.SqmTranslation;
|
||||||
import org.hibernate.query.sqm.sql.SqmTranslator;
|
import org.hibernate.query.sqm.sql.SqmTranslator;
|
||||||
import org.hibernate.query.sqm.sql.SqmTranslatorFactory;
|
import org.hibernate.query.sqm.sql.SqmTranslatorFactory;
|
||||||
|
@ -34,16 +35,16 @@ import org.hibernate.sql.exec.spi.JdbcUpdate;
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class SimpleUpdateQueryPlan implements NonSelectQueryPlan {
|
public class SimpleUpdateQueryPlan implements NonSelectQueryPlan {
|
||||||
private final SqmUpdateStatement sqmUpdate;
|
private final SqmUpdateStatement<?> sqmUpdate;
|
||||||
private final DomainParameterXref domainParameterXref;
|
private final DomainParameterXref domainParameterXref;
|
||||||
|
|
||||||
private JdbcUpdate jdbcUpdate;
|
private JdbcUpdate jdbcUpdate;
|
||||||
private FromClauseAccess tableGroupAccess;
|
private FromClauseAccess tableGroupAccess;
|
||||||
private Map<QueryParameterImplementor<?>, Map<SqmParameter, List<List<JdbcParameter>>>> jdbcParamsXref;
|
private Map<QueryParameterImplementor<?>, Map<SqmParameter<?>, List<List<JdbcParameter>>>> jdbcParamsXref;
|
||||||
private Map<SqmParameter,MappingModelExpressable> sqmParamMappingTypeResolutions;
|
private Map<SqmParameter<?>,MappingModelExpressable<?>> sqmParamMappingTypeResolutions;
|
||||||
|
|
||||||
public SimpleUpdateQueryPlan(
|
public SimpleUpdateQueryPlan(
|
||||||
SqmUpdateStatement sqmUpdate,
|
SqmUpdateStatement<?> sqmUpdate,
|
||||||
DomainParameterXref domainParameterXref) {
|
DomainParameterXref domainParameterXref) {
|
||||||
this.sqmUpdate = sqmUpdate;
|
this.sqmUpdate = sqmUpdate;
|
||||||
this.domainParameterXref = domainParameterXref;
|
this.domainParameterXref = domainParameterXref;
|
||||||
|
@ -66,7 +67,12 @@ public class SimpleUpdateQueryPlan implements NonSelectQueryPlan {
|
||||||
jdbcParamsXref,
|
jdbcParamsXref,
|
||||||
factory.getDomainModel(),
|
factory.getDomainModel(),
|
||||||
tableGroupAccess::findTableGroup,
|
tableGroupAccess::findTableGroup,
|
||||||
sqmParamMappingTypeResolutions::get,
|
new SqmParameterMappingModelResolutionAccess() {
|
||||||
|
@Override @SuppressWarnings("unchecked")
|
||||||
|
public <T> MappingModelExpressable<T> getResolvedMappingModelType(SqmParameter<T> parameter) {
|
||||||
|
return (MappingModelExpressable<T>) sqmParamMappingTypeResolutions.get(parameter);
|
||||||
|
}
|
||||||
|
},
|
||||||
session
|
session
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
import org.hibernate.NotYetImplementedFor6Exception;
|
import org.hibernate.NotYetImplementedFor6Exception;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
|
@ -70,7 +69,7 @@ public class SqmUtil {
|
||||||
private SqmUtil() {
|
private SqmUtil() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void verifyIsSelectStatement(SqmStatement sqm, String hqlString) {
|
public static void verifyIsSelectStatement(SqmStatement<?> sqm, String hqlString) {
|
||||||
if ( !(sqm instanceof SqmSelectStatement) ) {
|
if ( !(sqm instanceof SqmSelectStatement) ) {
|
||||||
throw new IllegalQueryOperationException(
|
throw new IllegalQueryOperationException(
|
||||||
String.format(
|
String.format(
|
||||||
|
@ -85,7 +84,7 @@ public class SqmUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void verifyIsNonSelectStatement(SqmStatement sqm, String hqlString) {
|
public static void verifyIsNonSelectStatement(SqmStatement<?> sqm, String hqlString) {
|
||||||
if ( !(sqm instanceof SqmDmlStatement) ) {
|
if ( !(sqm instanceof SqmDmlStatement) ) {
|
||||||
throw new IllegalQueryOperationException(
|
throw new IllegalQueryOperationException(
|
||||||
String.format(
|
String.format(
|
||||||
|
@ -100,7 +99,7 @@ public class SqmUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<QueryParameterImplementor<?>, Map<SqmParameter, List<List<JdbcParameter>>>> generateJdbcParamsXref(
|
public static Map<QueryParameterImplementor<?>, Map<SqmParameter<?>, List<List<JdbcParameter>>>> generateJdbcParamsXref(
|
||||||
DomainParameterXref domainParameterXref,
|
DomainParameterXref domainParameterXref,
|
||||||
JdbcParameterBySqmParameterAccess jdbcParameterBySqmParameterAccess) {
|
JdbcParameterBySqmParameterAccess jdbcParameterBySqmParameterAccess) {
|
||||||
if ( domainParameterXref == null || !domainParameterXref.hasParameters() ) {
|
if ( domainParameterXref == null || !domainParameterXref.hasParameters() ) {
|
||||||
|
@ -108,23 +107,23 @@ public class SqmUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
final int queryParameterCount = domainParameterXref.getQueryParameterCount();
|
final int queryParameterCount = domainParameterXref.getQueryParameterCount();
|
||||||
final Map<QueryParameterImplementor<?>, Map<SqmParameter, List<List<JdbcParameter>>>> result = new IdentityHashMap<>( queryParameterCount );
|
final Map<QueryParameterImplementor<?>, Map<SqmParameter<?>, List<List<JdbcParameter>>>> result = new IdentityHashMap<>( queryParameterCount );
|
||||||
|
|
||||||
for ( Map.Entry<QueryParameterImplementor<?>, List<SqmParameter>> entry : domainParameterXref.getSqmParamByQueryParam().entrySet() ) {
|
for ( Map.Entry<QueryParameterImplementor<?>, List<SqmParameter<?>>> entry : domainParameterXref.getSqmParamByQueryParam().entrySet() ) {
|
||||||
final QueryParameterImplementor<?> queryParam = entry.getKey();
|
final QueryParameterImplementor<?> queryParam = entry.getKey();
|
||||||
final List<SqmParameter> sqmParams = entry.getValue();
|
final List<SqmParameter<?>> sqmParams = entry.getValue();
|
||||||
|
|
||||||
final Map<SqmParameter, List<List<JdbcParameter>>> sqmParamMap = result.computeIfAbsent(
|
final Map<SqmParameter<?>, List<List<JdbcParameter>>> sqmParamMap = result.computeIfAbsent(
|
||||||
queryParam,
|
queryParam,
|
||||||
qp -> new IdentityHashMap<>( sqmParams.size() )
|
qp -> new IdentityHashMap<>( sqmParams.size() )
|
||||||
);
|
);
|
||||||
|
|
||||||
for ( SqmParameter sqmParam : sqmParams ) {
|
for ( SqmParameter<?> sqmParam : sqmParams ) {
|
||||||
sqmParamMap.put( sqmParam, jdbcParameterBySqmParameterAccess.getJdbcParamsBySqmParam().get( sqmParam ) );
|
sqmParamMap.put( sqmParam, jdbcParameterBySqmParameterAccess.getJdbcParamsBySqmParam().get( sqmParam ) );
|
||||||
|
|
||||||
final List<SqmParameter> expansions = domainParameterXref.getExpansions( sqmParam );
|
final List<SqmParameter<?>> expansions = domainParameterXref.getExpansions( sqmParam );
|
||||||
if ( ! expansions.isEmpty() ) {
|
if ( ! expansions.isEmpty() ) {
|
||||||
for ( SqmParameter expansion : expansions ) {
|
for ( SqmParameter<?> expansion : expansions ) {
|
||||||
sqmParamMap.put( expansion, jdbcParameterBySqmParameterAccess.getJdbcParamsBySqmParam().get( expansion ) );
|
sqmParamMap.put( expansion, jdbcParameterBySqmParameterAccess.getJdbcParamsBySqmParam().get( expansion ) );
|
||||||
result.put( queryParam, sqmParamMap );
|
result.put( queryParam, sqmParamMap );
|
||||||
}
|
}
|
||||||
|
@ -178,7 +177,7 @@ public class SqmUtil {
|
||||||
public static JdbcParameterBindings createJdbcParameterBindings(
|
public static JdbcParameterBindings createJdbcParameterBindings(
|
||||||
QueryParameterBindings domainParamBindings,
|
QueryParameterBindings domainParamBindings,
|
||||||
DomainParameterXref domainParameterXref,
|
DomainParameterXref domainParameterXref,
|
||||||
Map<QueryParameterImplementor<?>, Map<SqmParameter, List<List<JdbcParameter>>>> jdbcParamXref,
|
Map<QueryParameterImplementor<?>, Map<SqmParameter<?>, List<List<JdbcParameter>>>> jdbcParamXref,
|
||||||
MappingMetamodel domainModel,
|
MappingMetamodel domainModel,
|
||||||
Function<NavigablePath, TableGroup> tableGroupLocator,
|
Function<NavigablePath, TableGroup> tableGroupLocator,
|
||||||
SqmParameterMappingModelResolutionAccess mappingModelResolutionAccess,
|
SqmParameterMappingModelResolutionAccess mappingModelResolutionAccess,
|
||||||
|
@ -187,15 +186,15 @@ public class SqmUtil {
|
||||||
domainParameterXref.getSqmParameterCount()
|
domainParameterXref.getSqmParameterCount()
|
||||||
);
|
);
|
||||||
|
|
||||||
for ( Map.Entry<QueryParameterImplementor<?>, List<SqmParameter>> entry :
|
for ( Map.Entry<QueryParameterImplementor<?>, List<SqmParameter<?>>> entry :
|
||||||
domainParameterXref.getSqmParamByQueryParam().entrySet() ) {
|
domainParameterXref.getSqmParamByQueryParam().entrySet() ) {
|
||||||
final QueryParameterImplementor<?> queryParam = entry.getKey();
|
final QueryParameterImplementor<?> queryParam = entry.getKey();
|
||||||
final List<SqmParameter> sqmParameters = entry.getValue();
|
final List<SqmParameter<?>> sqmParameters = entry.getValue();
|
||||||
|
|
||||||
final QueryParameterBinding<?> domainParamBinding = domainParamBindings.getBinding( queryParam );
|
final QueryParameterBinding<?> domainParamBinding = domainParamBindings.getBinding( queryParam );
|
||||||
|
|
||||||
final Map<SqmParameter, List<List<JdbcParameter>>> jdbcParamMap = jdbcParamXref.get( queryParam );
|
final Map<SqmParameter<?>, List<List<JdbcParameter>>> jdbcParamMap = jdbcParamXref.get( queryParam );
|
||||||
sqm_params: for ( SqmParameter sqmParameter : sqmParameters ) {
|
for ( SqmParameter<?> sqmParameter : sqmParameters ) {
|
||||||
final Bindable parameterType = determineParameterType(
|
final Bindable parameterType = determineParameterType(
|
||||||
domainParamBinding,
|
domainParamBinding,
|
||||||
queryParam,
|
queryParam,
|
||||||
|
@ -211,12 +210,12 @@ public class SqmUtil {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ( !domainParamBinding.isBound() ) {
|
if ( !domainParamBinding.isBound() ) {
|
||||||
final MappingModelExpressable mappingExpressable = SqmMappingModelHelper.resolveMappingModelExpressable(
|
final MappingModelExpressable<?> mappingExpressable = SqmMappingModelHelper.resolveMappingModelExpressable(
|
||||||
sqmParameter,
|
sqmParameter,
|
||||||
domainModel,
|
domainModel,
|
||||||
tableGroupLocator
|
tableGroupLocator
|
||||||
);
|
);
|
||||||
jdbc_params: for ( int i = 0; i < jdbcParamsBinds.size(); i++ ) {
|
for ( int i = 0; i < jdbcParamsBinds.size(); i++ ) {
|
||||||
final List<JdbcParameter> jdbcParams = jdbcParamsBinds.get( i );
|
final List<JdbcParameter> jdbcParams = jdbcParamsBinds.get( i );
|
||||||
mappingExpressable.forEachJdbcType(
|
mappingExpressable.forEachJdbcType(
|
||||||
(position, jdbcType) -> {
|
(position, jdbcType) -> {
|
||||||
|
@ -248,11 +247,11 @@ public class SqmUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
// an then one for each of the expansions
|
// an then one for each of the expansions
|
||||||
final List<SqmParameter> expansions = domainParameterXref.getExpansions( sqmParameter );
|
final List<SqmParameter<?>> expansions = domainParameterXref.getExpansions( sqmParameter );
|
||||||
assert expansions.size() == bindValues.size() - 1;
|
assert expansions.size() == bindValues.size() - 1;
|
||||||
int expansionPosition = 0;
|
int expansionPosition = 0;
|
||||||
while ( valueItr.hasNext() ) {
|
while ( valueItr.hasNext() ) {
|
||||||
final SqmParameter expansionSqmParam = expansions.get( expansionPosition++ );
|
final SqmParameter<?> expansionSqmParam = expansions.get( expansionPosition++ );
|
||||||
final List<List<JdbcParameter>> jdbcParamBinds = jdbcParamMap.get( expansionSqmParam );
|
final List<List<JdbcParameter>> jdbcParamBinds = jdbcParamMap.get( expansionSqmParam );
|
||||||
for ( int i = 0; i < jdbcParamBinds.size(); i++ ) {
|
for ( int i = 0; i < jdbcParamBinds.size(); i++ ) {
|
||||||
List<JdbcParameter> expansionJdbcParams = jdbcParamBinds.get( i );
|
List<JdbcParameter> expansionJdbcParams = jdbcParamBinds.get( i );
|
||||||
|
@ -287,7 +286,7 @@ public class SqmUtil {
|
||||||
final JdbcMapping jdbcMapping;
|
final JdbcMapping jdbcMapping;
|
||||||
|
|
||||||
if ( domainParamBinding.getType() instanceof AttributeConverterTypeAdapter ) {
|
if ( domainParamBinding.getType() instanceof AttributeConverterTypeAdapter ) {
|
||||||
final AttributeConverterTypeAdapter adapter = (AttributeConverterTypeAdapter) domainParamBinding.getType();
|
final AttributeConverterTypeAdapter<?> adapter = (AttributeConverterTypeAdapter<?>) domainParamBinding.getType();
|
||||||
valueConverter = adapter.getAttributeConverter();
|
valueConverter = adapter.getAttributeConverter();
|
||||||
jdbcMapping = adapter.getJdbcMapping();
|
jdbcMapping = adapter.getJdbcMapping();
|
||||||
}
|
}
|
||||||
|
@ -310,7 +309,7 @@ public class SqmUtil {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
continue sqm_params;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,7 +393,7 @@ public class SqmUtil {
|
||||||
public static Bindable determineParameterType(
|
public static Bindable determineParameterType(
|
||||||
QueryParameterBinding<?> binding,
|
QueryParameterBinding<?> binding,
|
||||||
QueryParameterImplementor<?> parameter,
|
QueryParameterImplementor<?> parameter,
|
||||||
List<SqmParameter> sqmParameters,
|
List<SqmParameter<?>> sqmParameters,
|
||||||
SqmParameterMappingModelResolutionAccess mappingModelResolutionAccess,
|
SqmParameterMappingModelResolutionAccess mappingModelResolutionAccess,
|
||||||
SessionFactoryImplementor sessionFactory) {
|
SessionFactoryImplementor sessionFactory) {
|
||||||
if ( binding.getType() != null ) {
|
if ( binding.getType() != null ) {
|
||||||
|
|
|
@ -19,12 +19,14 @@ import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.metamodel.mapping.EntityIdentifierMapping;
|
import org.hibernate.metamodel.mapping.EntityIdentifierMapping;
|
||||||
import org.hibernate.metamodel.mapping.EntityMappingType;
|
import org.hibernate.metamodel.mapping.EntityMappingType;
|
||||||
|
import org.hibernate.metamodel.mapping.MappingModelExpressable;
|
||||||
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
|
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
|
||||||
import org.hibernate.metamodel.model.domain.EntityDomainType;
|
import org.hibernate.metamodel.model.domain.EntityDomainType;
|
||||||
import org.hibernate.query.spi.DomainQueryExecutionContext;
|
import org.hibernate.query.spi.DomainQueryExecutionContext;
|
||||||
import org.hibernate.query.sqm.internal.DomainParameterXref;
|
import org.hibernate.query.sqm.internal.DomainParameterXref;
|
||||||
import org.hibernate.query.sqm.internal.SqmJdbcExecutionContextAdapter;
|
import org.hibernate.query.sqm.internal.SqmJdbcExecutionContextAdapter;
|
||||||
import org.hibernate.query.sqm.internal.SqmUtil;
|
import org.hibernate.query.sqm.internal.SqmUtil;
|
||||||
|
import org.hibernate.query.sqm.spi.SqmParameterMappingModelResolutionAccess;
|
||||||
import org.hibernate.query.sqm.sql.internal.SqlAstQueryPartProcessingStateImpl;
|
import org.hibernate.query.sqm.sql.internal.SqlAstQueryPartProcessingStateImpl;
|
||||||
import org.hibernate.query.sqm.tree.SqmDeleteOrUpdateStatement;
|
import org.hibernate.query.sqm.tree.SqmDeleteOrUpdateStatement;
|
||||||
import org.hibernate.query.sqm.tree.expression.SqmParameter;
|
import org.hibernate.query.sqm.tree.expression.SqmParameter;
|
||||||
|
@ -281,10 +283,16 @@ public class MatchingIdSelectionHelper {
|
||||||
final JdbcParameterBindings jdbcParameterBindings = SqmUtil.createJdbcParameterBindings(
|
final JdbcParameterBindings jdbcParameterBindings = SqmUtil.createJdbcParameterBindings(
|
||||||
executionContext.getQueryParameterBindings(),
|
executionContext.getQueryParameterBindings(),
|
||||||
domainParameterXref,
|
domainParameterXref,
|
||||||
SqmUtil.generateJdbcParamsXref( domainParameterXref, sqmConverter ),
|
SqmUtil.generateJdbcParamsXref(domainParameterXref, sqmConverter),
|
||||||
factory.getDomainModel(),
|
factory.getDomainModel(),
|
||||||
navigablePath -> sqmConverter.getMutatingTableGroup(),
|
navigablePath -> sqmConverter.getMutatingTableGroup(),
|
||||||
sqmConverter.getSqmParameterMappingModelExpressableResolutions()::get,
|
new SqmParameterMappingModelResolutionAccess() {
|
||||||
|
@Override @SuppressWarnings("unchecked")
|
||||||
|
public <T> MappingModelExpressable<T> getResolvedMappingModelType(SqmParameter<T> parameter) {
|
||||||
|
return (MappingModelExpressable<T>) sqmConverter.getSqmParameterMappingModelExpressableResolutions().get(parameter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
,
|
||||||
executionContext.getSession()
|
executionContext.getSession()
|
||||||
);
|
);
|
||||||
final LockOptions lockOptions = executionContext.getQueryOptions().getLockOptions();
|
final LockOptions lockOptions = executionContext.getQueryOptions().getLockOptions();
|
||||||
|
|
|
@ -57,7 +57,7 @@ import org.hibernate.sql.ast.tree.update.Assignment;
|
||||||
*/
|
*/
|
||||||
public class MultiTableSqmMutationConverter extends BaseSqmToSqlAstConverter<Statement> {
|
public class MultiTableSqmMutationConverter extends BaseSqmToSqlAstConverter<Statement> {
|
||||||
public interface SqmParameterResolutionConsumer {
|
public interface SqmParameterResolutionConsumer {
|
||||||
void accept(SqmParameter sqmParam, MappingModelExpressable mappingType, List<JdbcParameter> jdbcParameters);
|
void accept(SqmParameter<?> sqmParam, MappingModelExpressable<?> mappingType, List<JdbcParameter> jdbcParameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final EntityMappingType mutatingEntityDescriptor;
|
private final EntityMappingType mutatingEntityDescriptor;
|
||||||
|
@ -231,7 +231,7 @@ public class MultiTableSqmMutationConverter extends BaseSqmToSqlAstConverter<Sta
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Expression consumeSingleSqmParameter(SqmParameter sqmParameter) {
|
protected Expression consumeSingleSqmParameter(SqmParameter<?> sqmParameter) {
|
||||||
assert parameterResolutionConsumer != null;
|
assert parameterResolutionConsumer != null;
|
||||||
|
|
||||||
final Expression expression = super.consumeSingleSqmParameter( sqmParameter );
|
final Expression expression = super.consumeSingleSqmParameter( sqmParameter );
|
||||||
|
|
|
@ -49,6 +49,7 @@ import org.hibernate.query.sqm.internal.SqmJdbcExecutionContextAdapter;
|
||||||
import org.hibernate.query.sqm.internal.SqmUtil;
|
import org.hibernate.query.sqm.internal.SqmUtil;
|
||||||
import org.hibernate.query.sqm.mutation.internal.InsertHandler;
|
import org.hibernate.query.sqm.mutation.internal.InsertHandler;
|
||||||
import org.hibernate.query.sqm.mutation.internal.MultiTableSqmMutationConverter;
|
import org.hibernate.query.sqm.mutation.internal.MultiTableSqmMutationConverter;
|
||||||
|
import org.hibernate.query.sqm.spi.SqmParameterMappingModelResolutionAccess;
|
||||||
import org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter;
|
import org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter;
|
||||||
import org.hibernate.query.sqm.tree.cte.SqmCteTable;
|
import org.hibernate.query.sqm.tree.cte.SqmCteTable;
|
||||||
import org.hibernate.query.sqm.tree.cte.SqmCteTableColumn;
|
import org.hibernate.query.sqm.tree.cte.SqmCteTableColumn;
|
||||||
|
@ -173,7 +174,7 @@ public class CteInsertHandler implements InsertHandler {
|
||||||
);
|
);
|
||||||
final TableGroup insertingTableGroup = sqmConverter.getMutatingTableGroup();
|
final TableGroup insertingTableGroup = sqmConverter.getMutatingTableGroup();
|
||||||
|
|
||||||
final Map<SqmParameter, List<List<JdbcParameter>>> parameterResolutions;
|
final Map<SqmParameter<?>, List<List<JdbcParameter>>> parameterResolutions;
|
||||||
if ( domainParameterXref.getSqmParameterCount() == 0 ) {
|
if ( domainParameterXref.getSqmParameterCount() == 0 ) {
|
||||||
parameterResolutions = Collections.emptyMap();
|
parameterResolutions = Collections.emptyMap();
|
||||||
}
|
}
|
||||||
|
@ -188,7 +189,7 @@ public class CteInsertHandler implements InsertHandler {
|
||||||
final int size = sqmStatement.getInsertionTargetPaths().size();
|
final int size = sqmStatement.getInsertionTargetPaths().size();
|
||||||
final List<Map.Entry<SqmCteTableColumn, Assignment>> targetPathColumns = new ArrayList<>( size );
|
final List<Map.Entry<SqmCteTableColumn, Assignment>> targetPathColumns = new ArrayList<>( size );
|
||||||
final List<SqmCteTableColumn> targetPathSqmCteColumns = new ArrayList<>( size );
|
final List<SqmCteTableColumn> targetPathSqmCteColumns = new ArrayList<>( size );
|
||||||
final Map<SqmParameter, MappingModelExpressable> paramTypeResolutions = new LinkedHashMap<>();
|
final Map<SqmParameter<?>, MappingModelExpressable<?>> paramTypeResolutions = new LinkedHashMap<>();
|
||||||
final NamedTableReference entityTableReference = new NamedTableReference(
|
final NamedTableReference entityTableReference = new NamedTableReference(
|
||||||
cteTable.getCteName(),
|
cteTable.getCteName(),
|
||||||
TemporaryTable.DEFAULT_ALIAS,
|
TemporaryTable.DEFAULT_ALIAS,
|
||||||
|
@ -629,7 +630,7 @@ public class CteInsertHandler implements InsertHandler {
|
||||||
|
|
||||||
final Expression count = createCountStar( factory, sqmConverter );
|
final Expression count = createCountStar( factory, sqmConverter );
|
||||||
domainResults.add(
|
domainResults.add(
|
||||||
new BasicResult<>(
|
new BasicResult(
|
||||||
0,
|
0,
|
||||||
null,
|
null,
|
||||||
( (SqlExpressable) count).getJdbcMapping().getJavaTypeDescriptor()
|
( (SqlExpressable) count).getJdbcMapping().getJavaTypeDescriptor()
|
||||||
|
@ -656,10 +657,15 @@ public class CteInsertHandler implements InsertHandler {
|
||||||
final JdbcParameterBindings jdbcParameterBindings = SqmUtil.createJdbcParameterBindings(
|
final JdbcParameterBindings jdbcParameterBindings = SqmUtil.createJdbcParameterBindings(
|
||||||
executionContext.getQueryParameterBindings(),
|
executionContext.getQueryParameterBindings(),
|
||||||
domainParameterXref,
|
domainParameterXref,
|
||||||
SqmUtil.generateJdbcParamsXref( domainParameterXref, sqmConverter ),
|
SqmUtil.generateJdbcParamsXref(domainParameterXref, sqmConverter),
|
||||||
factory.getDomainModel(),
|
factory.getDomainModel(),
|
||||||
navigablePath -> sqmConverter.getMutatingTableGroup(),
|
navigablePath -> sqmConverter.getMutatingTableGroup(),
|
||||||
paramTypeResolutions::get,
|
new SqmParameterMappingModelResolutionAccess() {
|
||||||
|
@Override @SuppressWarnings("unchecked")
|
||||||
|
public <T> MappingModelExpressable<T> getResolvedMappingModelType(SqmParameter<T> parameter) {
|
||||||
|
return (MappingModelExpressable<T>) paramTypeResolutions.get(parameter);
|
||||||
|
}
|
||||||
|
},
|
||||||
executionContext.getSession()
|
executionContext.getSession()
|
||||||
);
|
);
|
||||||
final JdbcSelect select = translator.translate( jdbcParameterBindings, executionContext.getQueryOptions() );
|
final JdbcSelect select = translator.translate( jdbcParameterBindings, executionContext.getQueryOptions() );
|
||||||
|
@ -694,7 +700,7 @@ public class CteInsertHandler implements InsertHandler {
|
||||||
List<Map.Entry<SqmCteTableColumn, Assignment>> assignments,
|
List<Map.Entry<SqmCteTableColumn, Assignment>> assignments,
|
||||||
boolean assignsId,
|
boolean assignsId,
|
||||||
MultiTableSqmMutationConverter sqmConverter,
|
MultiTableSqmMutationConverter sqmConverter,
|
||||||
Map<SqmParameter, List<List<JdbcParameter>>> parameterResolutions,
|
Map<SqmParameter<?>, List<List<JdbcParameter>>> parameterResolutions,
|
||||||
SessionFactoryImplementor factory) {
|
SessionFactoryImplementor factory) {
|
||||||
final TableGroup updatingTableGroup = sqmConverter.getMutatingTableGroup();
|
final TableGroup updatingTableGroup = sqmConverter.getMutatingTableGroup();
|
||||||
final EntityMappingType entityDescriptor = getEntityDescriptor();
|
final EntityMappingType entityDescriptor = getEntityDescriptor();
|
||||||
|
|
|
@ -42,6 +42,7 @@ import org.hibernate.query.spi.DomainQueryExecutionContext;
|
||||||
import org.hibernate.query.sqm.internal.DomainParameterXref;
|
import org.hibernate.query.sqm.internal.DomainParameterXref;
|
||||||
import org.hibernate.query.sqm.internal.SqmUtil;
|
import org.hibernate.query.sqm.internal.SqmUtil;
|
||||||
import org.hibernate.query.sqm.mutation.internal.MultiTableSqmMutationConverter;
|
import org.hibernate.query.sqm.mutation.internal.MultiTableSqmMutationConverter;
|
||||||
|
import org.hibernate.query.sqm.spi.SqmParameterMappingModelResolutionAccess;
|
||||||
import org.hibernate.query.sqm.tree.expression.SqmParameter;
|
import org.hibernate.query.sqm.tree.expression.SqmParameter;
|
||||||
import org.hibernate.query.sqm.tree.insert.SqmInsertStatement;
|
import org.hibernate.query.sqm.tree.insert.SqmInsertStatement;
|
||||||
import org.hibernate.sql.ast.tree.expression.ColumnReference;
|
import org.hibernate.sql.ast.tree.expression.ColumnReference;
|
||||||
|
@ -89,7 +90,7 @@ public class InsertExecutionDelegate implements TableBasedInsertHandler.Executio
|
||||||
private final JdbcParameterBindings jdbcParameterBindings;
|
private final JdbcParameterBindings jdbcParameterBindings;
|
||||||
|
|
||||||
private final Map<TableReference, List<Assignment>> assignmentsByTable;
|
private final Map<TableReference, List<Assignment>> assignmentsByTable;
|
||||||
private final Map<SqmParameter, MappingModelExpressable> paramTypeResolutions;
|
private final Map<SqmParameter<?>, MappingModelExpressable<?>> paramTypeResolutions;
|
||||||
private final SessionFactoryImplementor sessionFactory;
|
private final SessionFactoryImplementor sessionFactory;
|
||||||
|
|
||||||
public InsertExecutionDelegate(
|
public InsertExecutionDelegate(
|
||||||
|
@ -103,8 +104,8 @@ public class InsertExecutionDelegate implements TableBasedInsertHandler.Executio
|
||||||
Map<String, TableReference> tableReferenceByAlias,
|
Map<String, TableReference> tableReferenceByAlias,
|
||||||
List<Assignment> assignments,
|
List<Assignment> assignments,
|
||||||
InsertStatement insertStatement,
|
InsertStatement insertStatement,
|
||||||
Map<SqmParameter, List<List<JdbcParameter>>> parameterResolutions,
|
Map<SqmParameter<?>, List<List<JdbcParameter>>> parameterResolutions,
|
||||||
Map<SqmParameter, MappingModelExpressable> paramTypeResolutions,
|
Map<SqmParameter<?>, MappingModelExpressable<?>> paramTypeResolutions,
|
||||||
DomainQueryExecutionContext executionContext) {
|
DomainQueryExecutionContext executionContext) {
|
||||||
this.sqmInsert = sqmInsert;
|
this.sqmInsert = sqmInsert;
|
||||||
this.sqmConverter = sqmConverter;
|
this.sqmConverter = sqmConverter;
|
||||||
|
@ -134,7 +135,13 @@ public class InsertExecutionDelegate implements TableBasedInsertHandler.Executio
|
||||||
),
|
),
|
||||||
sessionFactory.getDomainModel(),
|
sessionFactory.getDomainModel(),
|
||||||
navigablePath -> insertingTableGroup,
|
navigablePath -> insertingTableGroup,
|
||||||
paramTypeResolutions::get,
|
new SqmParameterMappingModelResolutionAccess() {
|
||||||
|
@Override @SuppressWarnings("unchecked")
|
||||||
|
public <T> MappingModelExpressable<T> getResolvedMappingModelType(SqmParameter<T> parameter) {
|
||||||
|
return (MappingModelExpressable<T>) paramTypeResolutions.get(parameter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
,
|
||||||
executionContext.getSession()
|
executionContext.getSession()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ import org.hibernate.query.sqm.internal.SqmJdbcExecutionContextAdapter;
|
||||||
import org.hibernate.query.sqm.internal.SqmUtil;
|
import org.hibernate.query.sqm.internal.SqmUtil;
|
||||||
import org.hibernate.query.sqm.mutation.internal.MultiTableSqmMutationConverter;
|
import org.hibernate.query.sqm.mutation.internal.MultiTableSqmMutationConverter;
|
||||||
import org.hibernate.query.sqm.mutation.internal.SqmMutationStrategyHelper;
|
import org.hibernate.query.sqm.mutation.internal.SqmMutationStrategyHelper;
|
||||||
|
import org.hibernate.query.sqm.spi.SqmParameterMappingModelResolutionAccess;
|
||||||
import org.hibernate.query.sqm.tree.delete.SqmDeleteStatement;
|
import org.hibernate.query.sqm.tree.delete.SqmDeleteStatement;
|
||||||
import org.hibernate.query.sqm.tree.expression.SqmParameter;
|
import org.hibernate.query.sqm.tree.expression.SqmParameter;
|
||||||
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
||||||
|
@ -121,8 +122,8 @@ public class RestrictedDeleteExecutionDelegate implements TableBasedDeleteHandle
|
||||||
);
|
);
|
||||||
assert hierarchyRootTableReference != null;
|
assert hierarchyRootTableReference != null;
|
||||||
|
|
||||||
final Map<SqmParameter, List<List<JdbcParameter>>> parameterResolutions;
|
final Map<SqmParameter<?>, List<List<JdbcParameter>>> parameterResolutions;
|
||||||
final Map<SqmParameter, MappingModelExpressable> paramTypeResolutions;
|
final Map<SqmParameter<?>, MappingModelExpressable<?>> paramTypeResolutions;
|
||||||
|
|
||||||
if ( domainParameterXref.getSqmParameterCount() == 0 ) {
|
if ( domainParameterXref.getSqmParameterCount() == 0 ) {
|
||||||
parameterResolutions = Collections.emptyMap();
|
parameterResolutions = Collections.emptyMap();
|
||||||
|
@ -203,8 +204,8 @@ public class RestrictedDeleteExecutionDelegate implements TableBasedDeleteHandle
|
||||||
private int executeWithoutIdTable(
|
private int executeWithoutIdTable(
|
||||||
Predicate suppliedPredicate,
|
Predicate suppliedPredicate,
|
||||||
TableGroup tableGroup,
|
TableGroup tableGroup,
|
||||||
Map<SqmParameter, List<List<JdbcParameter>>> restrictionSqmParameterResolutions,
|
Map<SqmParameter<?>, List<List<JdbcParameter>>> restrictionSqmParameterResolutions,
|
||||||
Map<SqmParameter, MappingModelExpressable> paramTypeResolutions,
|
Map<SqmParameter<?>, MappingModelExpressable<?>> paramTypeResolutions,
|
||||||
SqlExpressionResolver sqlExpressionResolver,
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
ExecutionContext executionContext) {
|
ExecutionContext executionContext) {
|
||||||
assert entityDescriptor == entityDescriptor.getRootEntityDescriptor();
|
assert entityDescriptor == entityDescriptor.getRootEntityDescriptor();
|
||||||
|
@ -234,7 +235,12 @@ public class RestrictedDeleteExecutionDelegate implements TableBasedDeleteHandle
|
||||||
),
|
),
|
||||||
sessionFactory.getDomainModel(),
|
sessionFactory.getDomainModel(),
|
||||||
navigablePath -> tableGroup,
|
navigablePath -> tableGroup,
|
||||||
paramTypeResolutions::get,
|
new SqmParameterMappingModelResolutionAccess() {
|
||||||
|
@Override @SuppressWarnings("unchecked")
|
||||||
|
public <T> MappingModelExpressable<T> getResolvedMappingModelType(SqmParameter<T> parameter) {
|
||||||
|
return (MappingModelExpressable<T>) paramTypeResolutions.get(parameter);
|
||||||
|
}
|
||||||
|
},
|
||||||
executionContext.getSession()
|
executionContext.getSession()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -466,8 +472,8 @@ public class RestrictedDeleteExecutionDelegate implements TableBasedDeleteHandle
|
||||||
private int executeWithIdTable(
|
private int executeWithIdTable(
|
||||||
Predicate predicate,
|
Predicate predicate,
|
||||||
TableGroup deletingTableGroup,
|
TableGroup deletingTableGroup,
|
||||||
Map<SqmParameter, List<List<JdbcParameter>>> restrictionSqmParameterResolutions,
|
Map<SqmParameter<?>, List<List<JdbcParameter>>> restrictionSqmParameterResolutions,
|
||||||
Map<SqmParameter, MappingModelExpressable> paramTypeResolutions,
|
Map<SqmParameter<?>, MappingModelExpressable<?>> paramTypeResolutions,
|
||||||
ExecutionContext executionContext) {
|
ExecutionContext executionContext) {
|
||||||
final JdbcParameterBindings jdbcParameterBindings = SqmUtil.createJdbcParameterBindings(
|
final JdbcParameterBindings jdbcParameterBindings = SqmUtil.createJdbcParameterBindings(
|
||||||
executionContext.getQueryParameterBindings(),
|
executionContext.getQueryParameterBindings(),
|
||||||
|
@ -478,7 +484,12 @@ public class RestrictedDeleteExecutionDelegate implements TableBasedDeleteHandle
|
||||||
),
|
),
|
||||||
sessionFactory.getDomainModel(),
|
sessionFactory.getDomainModel(),
|
||||||
navigablePath -> deletingTableGroup,
|
navigablePath -> deletingTableGroup,
|
||||||
paramTypeResolutions::get,
|
new SqmParameterMappingModelResolutionAccess() {
|
||||||
|
@Override @SuppressWarnings("unchecked")
|
||||||
|
public <T> MappingModelExpressable<T> getResolvedMappingModelType(SqmParameter<T> parameter) {
|
||||||
|
return (MappingModelExpressable<T>) paramTypeResolutions.get(parameter);
|
||||||
|
}
|
||||||
|
},
|
||||||
executionContext.getSession()
|
executionContext.getSession()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class TableBasedDeleteHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SqmDeleteStatement getSqmDeleteOrUpdateStatement() {
|
public SqmDeleteStatement<?> getSqmDeleteOrUpdateStatement() {
|
||||||
return (SqmDeleteStatement) super.getSqmDeleteOrUpdateStatement();
|
return (SqmDeleteStatement<?>) super.getSqmDeleteOrUpdateStatement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,7 +129,7 @@ public class TableBasedInsertHandler implements InsertHandler {
|
||||||
|
|
||||||
final TableGroup insertingTableGroup = converterDelegate.getMutatingTableGroup();
|
final TableGroup insertingTableGroup = converterDelegate.getMutatingTableGroup();
|
||||||
|
|
||||||
final Map<SqmParameter, List<List<JdbcParameter>>> parameterResolutions;
|
final Map<SqmParameter<?>, List<List<JdbcParameter>>> parameterResolutions;
|
||||||
if ( domainParameterXref.getSqmParameterCount() == 0 ) {
|
if ( domainParameterXref.getSqmParameterCount() == 0 ) {
|
||||||
parameterResolutions = Collections.emptyMap();
|
parameterResolutions = Collections.emptyMap();
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ public class TableBasedInsertHandler implements InsertHandler {
|
||||||
// information about the target paths
|
// information about the target paths
|
||||||
|
|
||||||
final List<Assignment> targetPathColumns = new ArrayList<>();
|
final List<Assignment> targetPathColumns = new ArrayList<>();
|
||||||
final Map<SqmParameter, MappingModelExpressable> paramTypeResolutions = new LinkedHashMap<>();
|
final Map<SqmParameter<?>, MappingModelExpressable<?>> paramTypeResolutions = new LinkedHashMap<>();
|
||||||
final NamedTableReference entityTableReference = new NamedTableReference(
|
final NamedTableReference entityTableReference = new NamedTableReference(
|
||||||
entityTable.getTableExpression(),
|
entityTable.getTableExpression(),
|
||||||
TemporaryTable.DEFAULT_ALIAS,
|
TemporaryTable.DEFAULT_ALIAS,
|
||||||
|
|
|
@ -79,13 +79,13 @@ public class TableBasedUpdateHandler
|
||||||
this.entityDescriptor = sessionFactory.getDomainModel().getEntityDescriptor( targetEntityName );
|
this.entityDescriptor = sessionFactory.getDomainModel().getEntityDescriptor( targetEntityName );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SqmUpdateStatement getSqmUpdate() {
|
protected SqmUpdateStatement<?> getSqmUpdate() {
|
||||||
return getSqmDeleteOrUpdateStatement();
|
return getSqmDeleteOrUpdateStatement();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SqmUpdateStatement getSqmDeleteOrUpdateStatement() {
|
public SqmUpdateStatement<?> getSqmDeleteOrUpdateStatement() {
|
||||||
return (SqmUpdateStatement) super.getSqmDeleteOrUpdateStatement();
|
return (SqmUpdateStatement<?>) super.getSqmDeleteOrUpdateStatement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ public class TableBasedUpdateHandler
|
||||||
);
|
);
|
||||||
assert hierarchyRootTableReference != null;
|
assert hierarchyRootTableReference != null;
|
||||||
|
|
||||||
final Map<SqmParameter, List<List<JdbcParameter>>> parameterResolutions;
|
final Map<SqmParameter<?>, List<List<JdbcParameter>>> parameterResolutions;
|
||||||
if ( domainParameterXref.getSqmParameterCount() == 0 ) {
|
if ( domainParameterXref.getSqmParameterCount() == 0 ) {
|
||||||
parameterResolutions = Collections.emptyMap();
|
parameterResolutions = Collections.emptyMap();
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ public class TableBasedUpdateHandler
|
||||||
// information about the assignments
|
// information about the assignments
|
||||||
|
|
||||||
final List<Assignment> assignments = new ArrayList<>();
|
final List<Assignment> assignments = new ArrayList<>();
|
||||||
final Map<SqmParameter, MappingModelExpressable> paramTypeResolutions = new LinkedHashMap<>();
|
final Map<SqmParameter<?>, MappingModelExpressable<?>> paramTypeResolutions = new LinkedHashMap<>();
|
||||||
|
|
||||||
converterDelegate.visitSetClause(
|
converterDelegate.visitSetClause(
|
||||||
getSqmDeleteOrUpdateStatement().getSetClause(),
|
getSqmDeleteOrUpdateStatement().getSetClause(),
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.hibernate.query.spi.DomainQueryExecutionContext;
|
||||||
import org.hibernate.query.sqm.internal.DomainParameterXref;
|
import org.hibernate.query.sqm.internal.DomainParameterXref;
|
||||||
import org.hibernate.query.sqm.internal.SqmUtil;
|
import org.hibernate.query.sqm.internal.SqmUtil;
|
||||||
import org.hibernate.query.sqm.mutation.internal.MultiTableSqmMutationConverter;
|
import org.hibernate.query.sqm.mutation.internal.MultiTableSqmMutationConverter;
|
||||||
|
import org.hibernate.query.sqm.spi.SqmParameterMappingModelResolutionAccess;
|
||||||
import org.hibernate.query.sqm.tree.expression.SqmParameter;
|
import org.hibernate.query.sqm.tree.expression.SqmParameter;
|
||||||
import org.hibernate.query.sqm.tree.update.SqmUpdateStatement;
|
import org.hibernate.query.sqm.tree.update.SqmUpdateStatement;
|
||||||
import org.hibernate.sql.ast.tree.expression.ColumnReference;
|
import org.hibernate.sql.ast.tree.expression.ColumnReference;
|
||||||
|
@ -48,7 +49,7 @@ import org.hibernate.sql.exec.spi.JdbcUpdate;
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class UpdateExecutionDelegate implements TableBasedUpdateHandler.ExecutionDelegate {
|
public class UpdateExecutionDelegate implements TableBasedUpdateHandler.ExecutionDelegate {
|
||||||
private final SqmUpdateStatement sqmUpdate;
|
private final SqmUpdateStatement<?> sqmUpdate;
|
||||||
private final MultiTableSqmMutationConverter sqmConverter;
|
private final MultiTableSqmMutationConverter sqmConverter;
|
||||||
private final TemporaryTable idTable;
|
private final TemporaryTable idTable;
|
||||||
private final AfterUseAction afterUseAction;
|
private final AfterUseAction afterUseAction;
|
||||||
|
@ -62,7 +63,7 @@ public class UpdateExecutionDelegate implements TableBasedUpdateHandler.Executio
|
||||||
private final JdbcParameterBindings jdbcParameterBindings;
|
private final JdbcParameterBindings jdbcParameterBindings;
|
||||||
|
|
||||||
private final Map<TableReference, List<Assignment>> assignmentsByTable;
|
private final Map<TableReference, List<Assignment>> assignmentsByTable;
|
||||||
private final Map<SqmParameter, MappingModelExpressable> paramTypeResolutions;
|
private final Map<SqmParameter<?>, MappingModelExpressable<?>> paramTypeResolutions;
|
||||||
private final SessionFactoryImplementor sessionFactory;
|
private final SessionFactoryImplementor sessionFactory;
|
||||||
|
|
||||||
public UpdateExecutionDelegate(
|
public UpdateExecutionDelegate(
|
||||||
|
@ -77,8 +78,8 @@ public class UpdateExecutionDelegate implements TableBasedUpdateHandler.Executio
|
||||||
Map<String, TableReference> tableReferenceByAlias,
|
Map<String, TableReference> tableReferenceByAlias,
|
||||||
List<Assignment> assignments,
|
List<Assignment> assignments,
|
||||||
Predicate suppliedPredicate,
|
Predicate suppliedPredicate,
|
||||||
Map<SqmParameter, List<List<JdbcParameter>>> parameterResolutions,
|
Map<SqmParameter<?>, List<List<JdbcParameter>>> parameterResolutions,
|
||||||
Map<SqmParameter, MappingModelExpressable> paramTypeResolutions,
|
Map<SqmParameter<?>, MappingModelExpressable<?>> paramTypeResolutions,
|
||||||
DomainQueryExecutionContext executionContext) {
|
DomainQueryExecutionContext executionContext) {
|
||||||
this.sqmUpdate = sqmUpdate;
|
this.sqmUpdate = sqmUpdate;
|
||||||
this.sqmConverter = sqmConverter;
|
this.sqmConverter = sqmConverter;
|
||||||
|
@ -108,7 +109,12 @@ public class UpdateExecutionDelegate implements TableBasedUpdateHandler.Executio
|
||||||
),
|
),
|
||||||
sessionFactory.getDomainModel(),
|
sessionFactory.getDomainModel(),
|
||||||
navigablePath -> updatingTableGroup,
|
navigablePath -> updatingTableGroup,
|
||||||
paramTypeResolutions::get,
|
new SqmParameterMappingModelResolutionAccess() {
|
||||||
|
@Override @SuppressWarnings("unchecked")
|
||||||
|
public <T> MappingModelExpressable<T> getResolvedMappingModelType(SqmParameter<T> parameter) {
|
||||||
|
return (MappingModelExpressable<T>) paramTypeResolutions.get(parameter);
|
||||||
|
}
|
||||||
|
},
|
||||||
executionContext.getSession()
|
executionContext.getSession()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -134,14 +134,14 @@ public class PatternRenderer {
|
||||||
@SuppressWarnings({ "UnusedDeclaration" })
|
@SuppressWarnings({ "UnusedDeclaration" })
|
||||||
public void render(
|
public void render(
|
||||||
SqlAppender sqlAppender,
|
SqlAppender sqlAppender,
|
||||||
List<SqlAstNode> args,
|
List<? extends SqlAstNode> args,
|
||||||
SqlAstTranslator<?> translator) {
|
SqlAstTranslator<?> translator) {
|
||||||
render( sqlAppender, args, null, translator );
|
render( sqlAppender, args, null, translator );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void render(
|
public void render(
|
||||||
SqlAppender sqlAppender,
|
SqlAppender sqlAppender,
|
||||||
List<SqlAstNode> args,
|
List<? extends SqlAstNode> args,
|
||||||
Predicate filter,
|
Predicate filter,
|
||||||
SqlAstTranslator<?> translator) {
|
SqlAstTranslator<?> translator) {
|
||||||
final int numberOfArguments = args.size();
|
final int numberOfArguments = args.size();
|
||||||
|
|
|
@ -22,5 +22,5 @@ public interface JdbcParameterBySqmParameterAccess {
|
||||||
/**
|
/**
|
||||||
* The mapping between an SqmParameter and all of its JDBC parameters
|
* The mapping between an SqmParameter and all of its JDBC parameters
|
||||||
*/
|
*/
|
||||||
Map<SqmParameter, List<List<JdbcParameter>>> getJdbcParamsBySqmParam();
|
Map<SqmParameter<?>, List<List<JdbcParameter>>> getJdbcParamsBySqmParam();
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,7 +233,6 @@ import org.hibernate.sql.ast.spi.SqlAstQueryPartProcessingState;
|
||||||
import org.hibernate.sql.ast.spi.SqlAstTreeHelper;
|
import org.hibernate.sql.ast.spi.SqlAstTreeHelper;
|
||||||
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
||||||
import org.hibernate.sql.ast.spi.SqlSelection;
|
import org.hibernate.sql.ast.spi.SqlSelection;
|
||||||
import org.hibernate.sql.ast.tree.SqlAstNode;
|
|
||||||
import org.hibernate.sql.ast.tree.Statement;
|
import org.hibernate.sql.ast.tree.Statement;
|
||||||
import org.hibernate.sql.ast.tree.cte.CteColumn;
|
import org.hibernate.sql.ast.tree.cte.CteColumn;
|
||||||
import org.hibernate.sql.ast.tree.cte.CteStatement;
|
import org.hibernate.sql.ast.tree.cte.CteStatement;
|
||||||
|
@ -349,7 +348,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
|
|
||||||
private final DomainParameterXref domainParameterXref;
|
private final DomainParameterXref domainParameterXref;
|
||||||
private final QueryParameterBindings domainParameterBindings;
|
private final QueryParameterBindings domainParameterBindings;
|
||||||
private final Map<SqmParameter,MappingModelExpressable> sqmParameterMappingModelTypes = new LinkedHashMap<>();
|
private final Map<SqmParameter<?>,MappingModelExpressable<?>> sqmParameterMappingModelTypes = new LinkedHashMap<>();
|
||||||
private final Map<JpaCriteriaParameter<?>, SqmJpaCriteriaParameterWrapper<?>> jpaCriteriaParamResolutions;
|
private final Map<JpaCriteriaParameter<?>, SqmJpaCriteriaParameterWrapper<?>> jpaCriteriaParamResolutions;
|
||||||
private final List<DomainResult<?>> domainResults;
|
private final List<DomainResult<?>> domainResults;
|
||||||
private final EntityGraphTraversalState entityGraphTraversalState;
|
private final EntityGraphTraversalState entityGraphTraversalState;
|
||||||
|
@ -437,7 +436,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
.getJpaCriteriaParamResolutions();
|
.getJpaCriteriaParamResolutions();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<SqmParameter, MappingModelExpressable> getSqmParameterMappingModelExpressableResolutions() {
|
public Map<SqmParameter<?>,MappingModelExpressable<?>> getSqmParameterMappingModelExpressableResolutions() {
|
||||||
return sqmParameterMappingModelTypes;
|
return sqmParameterMappingModelTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -597,7 +596,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
// Update statement
|
// Update statement
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UpdateStatement visitUpdateStatement(SqmUpdateStatement sqmStatement) {
|
public UpdateStatement visitUpdateStatement(SqmUpdateStatement<?> sqmStatement) {
|
||||||
Map<String, CteStatement> cteStatements = this.visitCteContainer( sqmStatement );
|
Map<String, CteStatement> cteStatements = this.visitCteContainer( sqmStatement );
|
||||||
|
|
||||||
final SqmRoot<?> sqmTarget = sqmStatement.getTarget();
|
final SqmRoot<?> sqmTarget = sqmStatement.getTarget();
|
||||||
|
@ -754,9 +753,9 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
getFromClauseIndex()
|
getFromClauseIndex()
|
||||||
);
|
);
|
||||||
|
|
||||||
final SqmPathInterpretation assignedPathInterpretation;
|
final SqmPathInterpretation<?> assignedPathInterpretation;
|
||||||
try {
|
try {
|
||||||
assignedPathInterpretation = (SqmPathInterpretation) sqmAssignment.getTargetPath().accept( this );
|
assignedPathInterpretation = (SqmPathInterpretation<?>) sqmAssignment.getTargetPath().accept( this );
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
popProcessingStateStack();
|
popProcessingStateStack();
|
||||||
|
@ -764,7 +763,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
|
|
||||||
inferrableTypeAccessStack.push( assignedPathInterpretation::getExpressionType );
|
inferrableTypeAccessStack.push( assignedPathInterpretation::getExpressionType );
|
||||||
|
|
||||||
final List<ColumnReference> valueColumnReferences = new ArrayList<>();
|
// final List<ColumnReference> valueColumnReferences = new ArrayList<>();
|
||||||
pushProcessingState(
|
pushProcessingState(
|
||||||
new SqlAstProcessingStateImpl(
|
new SqlAstProcessingStateImpl(
|
||||||
getCurrentProcessingState(),
|
getCurrentProcessingState(),
|
||||||
|
@ -778,7 +777,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
.getSqlExpressionResolver()
|
.getSqlExpressionResolver()
|
||||||
.resolveSqlExpression( key, creator );
|
.resolveSqlExpression( key, creator );
|
||||||
assert expression instanceof ColumnReference;
|
assert expression instanceof ColumnReference;
|
||||||
valueColumnReferences.add( (ColumnReference) expression );
|
// valueColumnReferences.add( (ColumnReference) expression );
|
||||||
return expression;
|
return expression;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -858,7 +857,8 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
true,
|
true,
|
||||||
rootPath,
|
rootPath,
|
||||||
statement.getRoot().getAlias(),
|
statement.getRoot().getAlias(),
|
||||||
() -> predicate -> additionalRestrictions = SqlAstTreeHelper.combinePredicates( additionalRestrictions, predicate ),
|
() -> predicate -> additionalRestrictions
|
||||||
|
= SqlAstTreeHelper.combinePredicates( additionalRestrictions, predicate ),
|
||||||
this,
|
this,
|
||||||
getCreationContext()
|
getCreationContext()
|
||||||
);
|
);
|
||||||
|
@ -937,7 +937,8 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
true,
|
true,
|
||||||
rootPath,
|
rootPath,
|
||||||
sqmStatement.getTarget().getExplicitAlias(),
|
sqmStatement.getTarget().getExplicitAlias(),
|
||||||
() -> predicate -> additionalRestrictions = SqlAstTreeHelper.combinePredicates( additionalRestrictions, predicate ),
|
() -> predicate -> additionalRestrictions
|
||||||
|
= SqlAstTreeHelper.combinePredicates( additionalRestrictions, predicate ),
|
||||||
this,
|
this,
|
||||||
getCreationContext()
|
getCreationContext()
|
||||||
);
|
);
|
||||||
|
@ -1011,7 +1012,8 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
true,
|
true,
|
||||||
rootPath,
|
rootPath,
|
||||||
sqmStatement.getTarget().getExplicitAlias(),
|
sqmStatement.getTarget().getExplicitAlias(),
|
||||||
() -> predicate -> additionalRestrictions = SqlAstTreeHelper.combinePredicates( additionalRestrictions, predicate ),
|
() -> predicate -> additionalRestrictions
|
||||||
|
= SqlAstTreeHelper.combinePredicates( additionalRestrictions, predicate ),
|
||||||
this,
|
this,
|
||||||
getCreationContext()
|
getCreationContext()
|
||||||
);
|
);
|
||||||
|
@ -1042,8 +1044,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
throw new SemanticException( "Not expecting multiple table references for an SQM INSERT-SELECT" );
|
throw new SemanticException( "Not expecting multiple table references for an SQM INSERT-SELECT" );
|
||||||
}
|
}
|
||||||
|
|
||||||
List<SqmValues> valuesList = sqmStatement.getValuesList();
|
for ( SqmValues sqmValues : sqmStatement.getValuesList() ) {
|
||||||
for ( SqmValues sqmValues : valuesList ) {
|
|
||||||
final Values values = visitValues( sqmValues );
|
final Values values = visitValues( sqmValues );
|
||||||
additionalInsertValues.applyValues( values );
|
additionalInsertValues.applyValues( values );
|
||||||
insertStatement.getValuesList().add( values );
|
insertStatement.getValuesList().add( values );
|
||||||
|
@ -1249,7 +1250,8 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final String fragment = ( (BulkInsertionCapableIdentifierGenerator) identifierGenerator ).determineBulkInsertionIdentifierGenerationSelectFragment(
|
final String fragment = ( (BulkInsertionCapableIdentifierGenerator) identifierGenerator )
|
||||||
|
.determineBulkInsertionIdentifierGenerationSelectFragment(
|
||||||
sessionFactory.getSqlStringGenerationContext()
|
sessionFactory.getSqlStringGenerationContext()
|
||||||
);
|
);
|
||||||
// The position is irrelevant as this is only needed for insert
|
// The position is irrelevant as this is only needed for insert
|
||||||
|
@ -1392,15 +1394,13 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
forEachCteColumn(
|
forEachCteColumn(
|
||||||
cteTable,
|
cteTable,
|
||||||
specification.getCteColumn(),
|
specification.getCteColumn(),
|
||||||
cteColumn -> {
|
cteColumn -> searchClauseSpecifications.add(
|
||||||
searchClauseSpecifications.add(
|
|
||||||
new SearchClauseSpecification(
|
new SearchClauseSpecification(
|
||||||
cteColumn,
|
cteColumn,
|
||||||
specification.getSortOrder(),
|
specification.getSortOrder(),
|
||||||
specification.getNullPrecedence()
|
specification.getNullPrecedence()
|
||||||
)
|
)
|
||||||
);
|
)
|
||||||
}
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1473,14 +1473,12 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
}
|
}
|
||||||
if ( valueMapping instanceof EmbeddableValuedModelPart ) {
|
if ( valueMapping instanceof EmbeddableValuedModelPart ) {
|
||||||
valueMapping.forEachJdbcType(
|
valueMapping.forEachJdbcType(
|
||||||
(index, jdbcMapping) -> {
|
(index, jdbcMapping) -> sqlCteColumns.add(
|
||||||
sqlCteColumns.add(
|
|
||||||
new CteColumn(
|
new CteColumn(
|
||||||
sqmCteTableColumn.getColumnName() + "_" + index,
|
sqmCteTableColumn.getColumnName() + "_" + index,
|
||||||
jdbcMapping
|
jdbcMapping
|
||||||
)
|
)
|
||||||
);
|
)
|
||||||
}
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1715,13 +1713,13 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
final TableGroup root = roots.get( 0 );
|
final TableGroup root = roots.get( 0 );
|
||||||
|
|
||||||
if ( CollectionHelper.isNotEmpty( collectionFilterPredicates ) ) {
|
if ( CollectionHelper.isNotEmpty( collectionFilterPredicates ) ) {
|
||||||
root.getTableGroupJoins().forEach( (tableGroupJoin) -> {
|
root.getTableGroupJoins().forEach( (tableGroupJoin) ->
|
||||||
collectionFilterPredicates.forEach( (alias, predicates) -> {
|
collectionFilterPredicates.forEach( (alias, predicates) -> {
|
||||||
if ( tableGroupJoin.getJoinedGroup().getGroupAlias().equals( alias ) ) {
|
if ( tableGroupJoin.getJoinedGroup().getGroupAlias().equals( alias ) ) {
|
||||||
tableGroupJoin.applyPredicate( predicates.getPredicate() );
|
tableGroupJoin.applyPredicate( predicates.getPredicate() );
|
||||||
}
|
}
|
||||||
} );
|
} )
|
||||||
} );
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2036,13 +2034,13 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public QuerySpec visitOffsetAndFetchExpressions(QuerySpec sqlQuerySpec, SqmQuerySpec<?> sqmQuerySpec) {
|
// public QuerySpec visitOffsetAndFetchExpressions(QuerySpec sqlQuerySpec, SqmQuerySpec<?> sqmQuerySpec) {
|
||||||
final Expression offsetExpression = visitOffsetExpression( sqmQuerySpec.getOffsetExpression() );
|
// final Expression offsetExpression = visitOffsetExpression( sqmQuerySpec.getOffsetExpression() );
|
||||||
final Expression fetchExpression = visitFetchExpression( sqmQuerySpec.getFetchExpression() );
|
// final Expression fetchExpression = visitFetchExpression( sqmQuerySpec.getFetchExpression() );
|
||||||
sqlQuerySpec.setOffsetClauseExpression( offsetExpression );
|
// sqlQuerySpec.setOffsetClauseExpression( offsetExpression );
|
||||||
sqlQuerySpec.setFetchClauseExpression( fetchExpression, sqmQuerySpec.getFetchClauseType() );
|
// sqlQuerySpec.setFetchClauseExpression( fetchExpression, sqmQuerySpec.getFetchClauseType() );
|
||||||
return sqlQuerySpec;
|
// return sqlQuerySpec;
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Expression visitOffsetExpression(SqmExpression<?> expression) {
|
public Expression visitOffsetExpression(SqmExpression<?> expression) {
|
||||||
|
@ -2958,7 +2956,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Expression visitQualifiedEntityJoin(SqmEntityJoin sqmJoin) {
|
public Expression visitQualifiedEntityJoin(SqmEntityJoin<?> sqmJoin) {
|
||||||
// todo (6.0) : have this resolve to TableGroup instead?
|
// todo (6.0) : have this resolve to TableGroup instead?
|
||||||
// - trying to remove tracking of TableGroupJoin in the x-refs
|
// - trying to remove tracking of TableGroupJoin in the x-refs
|
||||||
|
|
||||||
|
@ -3028,7 +3026,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
EntityMappingType mappingType;
|
EntityMappingType mappingType;
|
||||||
if ( path instanceof SqmTreatedPath ) {
|
if ( path instanceof SqmTreatedPath ) {
|
||||||
mappingType = creationContext.getDomainModel()
|
mappingType = creationContext.getDomainModel()
|
||||||
.findEntityDescriptor( ( (SqmTreatedPath) path ).getTreatTarget().getHibernateEntityName() );
|
.findEntityDescriptor( ( (SqmTreatedPath<?,?>) path ).getTreatTarget().getHibernateEntityName() );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mappingType = mapping.getEntityMappingType();
|
mappingType = mapping.getEntityMappingType();
|
||||||
|
@ -3371,7 +3369,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
.getBasicTypeForJavaType( Integer.class );
|
.getBasicTypeForJavaType( Integer.class );
|
||||||
final Expression expression = new SelfRenderingAggregateFunctionSqlAstExpression(
|
final Expression expression = new SelfRenderingAggregateFunctionSqlAstExpression(
|
||||||
functionDescriptor.getName(),
|
functionDescriptor.getName(),
|
||||||
functionDescriptor::render,
|
functionDescriptor,
|
||||||
Collections.singletonList( new QueryLiteral<>( 1, integerType ) ),
|
Collections.singletonList( new QueryLiteral<>( 1, integerType ) ),
|
||||||
null,
|
null,
|
||||||
integerType,
|
integerType,
|
||||||
|
@ -3537,8 +3535,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
tupleElements = new ArrayList<>( jdbcTypeCount );
|
tupleElements = new ArrayList<>( jdbcTypeCount );
|
||||||
}
|
}
|
||||||
modelPart.forEachSelectable(
|
modelPart.forEachSelectable(
|
||||||
(selectionIndex, selectionMapping) -> {
|
(selectionIndex, selectionMapping) -> tupleElements.add(
|
||||||
tupleElements.add(
|
|
||||||
new ColumnReference(
|
new ColumnReference(
|
||||||
tableGroup.resolveTableReference(
|
tableGroup.resolveTableReference(
|
||||||
navigablePath,
|
navigablePath,
|
||||||
|
@ -3547,25 +3544,25 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
selectionMapping,
|
selectionMapping,
|
||||||
creationContext.getSessionFactory()
|
creationContext.getSessionFactory()
|
||||||
)
|
)
|
||||||
);
|
)
|
||||||
}
|
|
||||||
);
|
);
|
||||||
if ( jdbcTypeCount != 1 ) {
|
if ( jdbcTypeCount != 1 ) {
|
||||||
arguments.add( new SqlTuple( tupleElements, modelPart ) );
|
arguments.add( new SqlTuple( tupleElements, modelPart ) );
|
||||||
}
|
}
|
||||||
final Expression expression = new SelfRenderingAggregateFunctionSqlAstExpression(
|
final Expression expression = new SelfRenderingAggregateFunctionSqlAstExpression(
|
||||||
functionDescriptor.getName(),
|
functionDescriptor.getName(),
|
||||||
functionDescriptor::render,
|
functionDescriptor,
|
||||||
(List<SqlAstNode>) (List<?>) arguments,
|
arguments,
|
||||||
null,
|
null,
|
||||||
(AllowableFunctionReturnType<?>) modelPart.getJdbcMappings().get( 0 ),
|
(AllowableFunctionReturnType<?>) modelPart.getJdbcMappings().get( 0 ),
|
||||||
modelPart
|
modelPart
|
||||||
);
|
);
|
||||||
subQuerySpec.getSelectClause().addSqlSelection( new SqlSelectionImpl( 1, 0, expression ) );
|
subQuerySpec.getSelectClause().addSqlSelection( new SqlSelectionImpl( 1, 0, expression ) );
|
||||||
|
|
||||||
|
NavigablePath parent = pluralPartPath.getPluralDomainPath().getNavigablePath().getParent();
|
||||||
subQuerySpec.applyPredicate(
|
subQuerySpec.applyPredicate(
|
||||||
pluralAttributeMapping.getKeyDescriptor().generateJoinPredicate(
|
pluralAttributeMapping.getKeyDescriptor().generateJoinPredicate(
|
||||||
parentFromClauseAccess.findTableGroup( pluralPartPath.getPluralDomainPath().getNavigablePath().getParent() ),
|
parentFromClauseAccess.findTableGroup( parent ),
|
||||||
tableGroup,
|
tableGroup,
|
||||||
SqlAstJoinType.INNER,
|
SqlAstJoinType.INNER,
|
||||||
getSqlExpressionResolver(),
|
getSqlExpressionResolver(),
|
||||||
|
@ -3776,8 +3773,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
else {
|
else {
|
||||||
final List<ColumnReference> resultColumnReferences = new ArrayList<>( jdbcTypeCount );
|
final List<ColumnReference> resultColumnReferences = new ArrayList<>( jdbcTypeCount );
|
||||||
modelPart.forEachSelectable(
|
modelPart.forEachSelectable(
|
||||||
(selectionIndex, selectionMapping) -> {
|
(selectionIndex, selectionMapping) -> resultColumnReferences.add(
|
||||||
resultColumnReferences.add(
|
|
||||||
new ColumnReference(
|
new ColumnReference(
|
||||||
identifierVariable,
|
identifierVariable,
|
||||||
tableReference.getColumnNames().get( selectionIndex ),
|
tableReference.getColumnNames().get( selectionIndex ),
|
||||||
|
@ -3787,8 +3783,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
selectionMapping.getJdbcMapping(),
|
selectionMapping.getJdbcMapping(),
|
||||||
creationContext.getSessionFactory()
|
creationContext.getSessionFactory()
|
||||||
)
|
)
|
||||||
);
|
)
|
||||||
}
|
|
||||||
);
|
);
|
||||||
return new SqlTuple( resultColumnReferences, modelPart );
|
return new SqlTuple( resultColumnReferences, modelPart );
|
||||||
}
|
}
|
||||||
|
@ -3851,7 +3846,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Expression visitLiteral(SqmLiteral<?> literal) {
|
public Expression visitLiteral(SqmLiteral<?> literal) {
|
||||||
final Supplier<MappingModelExpressable> inferableTypeAccess = inferrableTypeAccessStack.getCurrent();
|
final Supplier<MappingModelExpressable<?>> inferableTypeAccess = inferrableTypeAccessStack.getCurrent();
|
||||||
|
|
||||||
if ( literal instanceof SqmLiteralNull ) {
|
if ( literal instanceof SqmLiteralNull ) {
|
||||||
MappingModelExpressable<?> mappingModelExpressable = inferableTypeAccess.get();
|
MappingModelExpressable<?> mappingModelExpressable = inferableTypeAccess.get();
|
||||||
|
@ -3884,7 +3879,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
|
|
||||||
if ( inferableExpressable instanceof ConvertibleModelPart ) {
|
if ( inferableExpressable instanceof ConvertibleModelPart ) {
|
||||||
final ConvertibleModelPart convertibleModelPart = (ConvertibleModelPart) inferableExpressable;
|
final ConvertibleModelPart convertibleModelPart = (ConvertibleModelPart) inferableExpressable;
|
||||||
final BasicValueConverter<Object, Object> valueConverter = convertibleModelPart.getValueConverter();
|
final BasicValueConverter valueConverter = convertibleModelPart.getValueConverter();
|
||||||
|
|
||||||
if ( valueConverter != null ) {
|
if ( valueConverter != null ) {
|
||||||
final Object literalValue = literal.getLiteralValue();
|
final Object literalValue = literal.getLiteralValue();
|
||||||
|
@ -3980,9 +3975,8 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
embeddableValuedModelPart.forEachJdbcValue(
|
embeddableValuedModelPart.forEachJdbcValue(
|
||||||
literal.getLiteralValue(),
|
literal.getLiteralValue(),
|
||||||
null,
|
null,
|
||||||
(selectionIndex, value, jdbcMapping) -> {
|
(selectionIndex, value, jdbcMapping)
|
||||||
list.add( new QueryLiteral<>( value, (BasicValuedMapping) jdbcMapping ) );
|
-> list.add( new QueryLiteral<>( value, (BasicValuedMapping) jdbcMapping ) ),
|
||||||
},
|
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
return new SqlTuple( list, expressable );
|
return new SqlTuple( list, expressable );
|
||||||
|
@ -4021,9 +4015,8 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
associationKeyPart.forEachJdbcValue(
|
associationKeyPart.forEachJdbcValue(
|
||||||
associationKey,
|
associationKey,
|
||||||
null,
|
null,
|
||||||
(selectionIndex, value, jdbcMapping) -> {
|
(selectionIndex, value, jdbcMapping)
|
||||||
list.add( new QueryLiteral<>( value, (BasicValuedMapping) jdbcMapping ) );
|
-> list.add( new QueryLiteral<>( value, (BasicValuedMapping) jdbcMapping ) ),
|
||||||
},
|
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
return new SqlTuple( list, associationKeyPart );
|
return new SqlTuple( list, associationKeyPart );
|
||||||
|
@ -4054,11 +4047,11 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Map<SqmParameter, List<List<JdbcParameter>>> jdbcParamsBySqmParam = new IdentityHashMap<>();
|
private final Map<SqmParameter<?>, List<List<JdbcParameter>>> jdbcParamsBySqmParam = new IdentityHashMap<>();
|
||||||
private final JdbcParameters jdbcParameters = new JdbcParametersImpl();
|
private final JdbcParameters jdbcParameters = new JdbcParametersImpl();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<SqmParameter, List<List<JdbcParameter>>> getJdbcParamsBySqmParam() {
|
public Map<SqmParameter<?>, List<List<JdbcParameter>>> getJdbcParamsBySqmParam() {
|
||||||
return jdbcParamsBySqmParam;
|
return jdbcParamsBySqmParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4068,9 +4061,9 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Expression consumeSqmParameter(
|
protected Expression consumeSqmParameter(
|
||||||
SqmParameter sqmParameter,
|
SqmParameter<?> sqmParameter,
|
||||||
BiConsumer<Integer,JdbcParameter> jdbcParameterConsumer) {
|
BiConsumer<Integer,JdbcParameter> jdbcParameterConsumer) {
|
||||||
final MappingModelExpressable valueMapping = determineValueMapping( sqmParameter );
|
final MappingModelExpressable<?> valueMapping = determineValueMapping( sqmParameter );
|
||||||
|
|
||||||
final List<JdbcParameter> jdbcParametersForSqm = new ArrayList<>();
|
final List<JdbcParameter> jdbcParametersForSqm = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -4089,7 +4082,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
.add( jdbcParametersForSqm );
|
.add( jdbcParametersForSqm );
|
||||||
|
|
||||||
final QueryParameterImplementor<?> queryParameter = domainParameterXref.getQueryParameter( sqmParameter );
|
final QueryParameterImplementor<?> queryParameter = domainParameterXref.getQueryParameter( sqmParameter );
|
||||||
final QueryParameterBinding<?> binding = domainParameterBindings.getBinding( queryParameter );
|
final QueryParameterBinding binding = domainParameterBindings.getBinding( queryParameter );
|
||||||
if ( binding.setType( valueMapping ) ) {
|
if ( binding.setType( valueMapping ) ) {
|
||||||
replaceJdbcParametersType(
|
replaceJdbcParametersType(
|
||||||
sqmParameter,
|
sqmParameter,
|
||||||
|
@ -4107,8 +4100,8 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
}
|
}
|
||||||
|
|
||||||
private void replaceJdbcParametersType(
|
private void replaceJdbcParametersType(
|
||||||
SqmParameter sourceSqmParameter,
|
SqmParameter<?> sourceSqmParameter,
|
||||||
List<SqmParameter> sqmParameters,
|
List<SqmParameter<?>> sqmParameters,
|
||||||
MappingModelExpressable<?> valueMapping) {
|
MappingModelExpressable<?> valueMapping) {
|
||||||
final JdbcMapping jdbcMapping = valueMapping.getJdbcMappings().get( 0 );
|
final JdbcMapping jdbcMapping = valueMapping.getJdbcMappings().get( 0 );
|
||||||
for ( SqmParameter<?> sqmParameter : sqmParameters ) {
|
for ( SqmParameter<?> sqmParameter : sqmParameters ) {
|
||||||
|
@ -4132,20 +4125,20 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Expression consumeSqmParameter(SqmParameter sqmParameter) {
|
protected Expression consumeSqmParameter(SqmParameter<?> sqmParameter) {
|
||||||
if ( sqmParameter.allowMultiValuedBinding() ) {
|
if ( sqmParameter.allowMultiValuedBinding() ) {
|
||||||
final QueryParameterImplementor<?> domainParam = domainParameterXref.getQueryParameter( sqmParameter );
|
final QueryParameterImplementor<?> domainParam = domainParameterXref.getQueryParameter( sqmParameter );
|
||||||
final QueryParameterBinding domainParamBinding = domainParameterBindings.getBinding( domainParam );
|
final QueryParameterBinding<?> domainParamBinding = domainParameterBindings.getBinding( domainParam );
|
||||||
|
|
||||||
if ( !domainParamBinding.isMultiValued() ) {
|
if ( !domainParamBinding.isMultiValued() ) {
|
||||||
return consumeSingleSqmParameter( sqmParameter );
|
return consumeSingleSqmParameter( sqmParameter );
|
||||||
}
|
}
|
||||||
|
|
||||||
final Collection bindValues = domainParamBinding.getBindValues();
|
final Collection<?> bindValues = domainParamBinding.getBindValues();
|
||||||
final List<Expression> expressions = new ArrayList<>( bindValues.size());
|
final List<Expression> expressions = new ArrayList<>( bindValues.size());
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
for ( Object bindValue : bindValues ) {
|
for ( Object bindValue : bindValues ) {
|
||||||
final SqmParameter sqmParamToConsume;
|
final SqmParameter<?> sqmParamToConsume;
|
||||||
// for each bind value create an "expansion"
|
// for each bind value create an "expansion"
|
||||||
if ( first ) {
|
if ( first ) {
|
||||||
sqmParamToConsume = sqmParameter;
|
sqmParamToConsume = sqmParameter;
|
||||||
|
@ -4165,8 +4158,8 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Expression consumeSingleSqmParameter(SqmParameter sqmParameter) {
|
protected Expression consumeSingleSqmParameter(SqmParameter<?> sqmParameter) {
|
||||||
final MappingModelExpressable valueMapping = determineValueMapping( sqmParameter );
|
final MappingModelExpressable<?> valueMapping = determineValueMapping( sqmParameter );
|
||||||
|
|
||||||
final List<JdbcParameter> jdbcParametersForSqm = new ArrayList<>();
|
final List<JdbcParameter> jdbcParametersForSqm = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -4182,7 +4175,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
.add( jdbcParametersForSqm );
|
.add( jdbcParametersForSqm );
|
||||||
|
|
||||||
final QueryParameterImplementor<?> queryParameter = domainParameterXref.getQueryParameter( sqmParameter );
|
final QueryParameterImplementor<?> queryParameter = domainParameterXref.getQueryParameter( sqmParameter );
|
||||||
final QueryParameterBinding<?> binding = domainParameterBindings.getBinding( queryParameter );
|
final QueryParameterBinding binding = domainParameterBindings.getBinding( queryParameter );
|
||||||
if ( binding.setType( valueMapping ) ) {
|
if ( binding.setType( valueMapping ) ) {
|
||||||
replaceJdbcParametersType(
|
replaceJdbcParametersType(
|
||||||
sqmParameter,
|
sqmParameter,
|
||||||
|
@ -4199,33 +4192,33 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected MappingModelExpressable<?> lenientlyResolveMappingExpressable(SqmExpressable<?> nodeType) {
|
// protected MappingModelExpressable<?> lenientlyResolveMappingExpressable(SqmExpressable<?> nodeType) {
|
||||||
return resolveMappingExpressable( nodeType );
|
// return resolveMappingExpressable( nodeType );
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
protected MappingModelExpressable<?> resolveMappingExpressable(SqmExpressable<?> nodeType) {
|
// protected MappingModelExpressable<?> resolveMappingExpressable(SqmExpressable<?> nodeType) {
|
||||||
final MappingModelExpressable valueMapping = getCreationContext().getDomainModel().resolveMappingExpressable(
|
// final MappingModelExpressable<?> valueMapping = getCreationContext().getDomainModel().resolveMappingExpressable(
|
||||||
nodeType,
|
// nodeType,
|
||||||
this::findTableGroupByPath
|
// this::findTableGroupByPath
|
||||||
);
|
// );
|
||||||
|
//
|
||||||
if ( valueMapping == null ) {
|
// if ( valueMapping == null ) {
|
||||||
final Supplier<MappingModelExpressable> currentExpressableSupplier = inferrableTypeAccessStack.getCurrent();
|
// final Supplier<MappingModelExpressable<?>> currentExpressableSupplier = inferrableTypeAccessStack.getCurrent();
|
||||||
if ( currentExpressableSupplier != null ) {
|
// if ( currentExpressableSupplier != null ) {
|
||||||
return currentExpressableSupplier.get();
|
// return currentExpressableSupplier.get();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if ( valueMapping == null ) {
|
// if ( valueMapping == null ) {
|
||||||
throw new ConversionException( "Could not determine ValueMapping for SqmExpressable: " + nodeType );
|
// throw new ConversionException( "Could not determine ValueMapping for SqmExpressable: " + nodeType );
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return valueMapping;
|
// return valueMapping;
|
||||||
}
|
// }
|
||||||
|
|
||||||
protected MappingModelExpressable<?> determineValueMapping(SqmExpression<?> sqmExpression) {
|
protected MappingModelExpressable<?> determineValueMapping(SqmExpression<?> sqmExpression) {
|
||||||
if ( sqmExpression instanceof SqmParameter ) {
|
if ( sqmExpression instanceof SqmParameter ) {
|
||||||
return determineValueMapping( (SqmParameter) sqmExpression );
|
return determineValueMapping( (SqmParameter<?>) sqmExpression );
|
||||||
}
|
}
|
||||||
|
|
||||||
final MappingMetamodel domainModel = getCreationContext().getDomainModel();
|
final MappingMetamodel domainModel = getCreationContext().getDomainModel();
|
||||||
|
@ -4241,7 +4234,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
|
|
||||||
// The model type of an enum literal is always inferred
|
// The model type of an enum literal is always inferred
|
||||||
if ( sqmExpression instanceof SqmEnumLiteral<?> ) {
|
if ( sqmExpression instanceof SqmEnumLiteral<?> ) {
|
||||||
final Supplier<MappingModelExpressable> currentExpressableSupplier = inferrableTypeAccessStack.getCurrent();
|
final Supplier<MappingModelExpressable<?>> currentExpressableSupplier = inferrableTypeAccessStack.getCurrent();
|
||||||
if ( currentExpressableSupplier != null ) {
|
if ( currentExpressableSupplier != null ) {
|
||||||
return currentExpressableSupplier.get();
|
return currentExpressableSupplier.get();
|
||||||
}
|
}
|
||||||
|
@ -4304,13 +4297,13 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
// We can't determine the type of the expression
|
// We can't determine the type of the expression
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final MappingModelExpressable valueMapping = domainModel.resolveMappingExpressable(
|
final MappingModelExpressable<?> valueMapping = domainModel.resolveMappingExpressable(
|
||||||
nodeType,
|
nodeType,
|
||||||
this::findTableGroupByPath
|
this::findTableGroupByPath
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( valueMapping == null ) {
|
if ( valueMapping == null ) {
|
||||||
final Supplier<MappingModelExpressable> currentExpressableSupplier = inferrableTypeAccessStack.getCurrent();
|
final Supplier<MappingModelExpressable<?>> currentExpressableSupplier = inferrableTypeAccessStack.getCurrent();
|
||||||
if ( currentExpressableSupplier != null ) {
|
if ( currentExpressableSupplier != null ) {
|
||||||
return currentExpressableSupplier.get();
|
return currentExpressableSupplier.get();
|
||||||
}
|
}
|
||||||
|
@ -4324,9 +4317,9 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
}
|
}
|
||||||
|
|
||||||
protected MappingModelExpressable<?> getInferredValueMapping() {
|
protected MappingModelExpressable<?> getInferredValueMapping() {
|
||||||
final Supplier<MappingModelExpressable> currentExpressableSupplier = inferrableTypeAccessStack.getCurrent();
|
final Supplier<MappingModelExpressable<?>> currentExpressableSupplier = inferrableTypeAccessStack.getCurrent();
|
||||||
if ( currentExpressableSupplier != null ) {
|
if ( currentExpressableSupplier != null ) {
|
||||||
final MappingModelExpressable inferredMapping = currentExpressableSupplier.get();
|
final MappingModelExpressable<?> inferredMapping = currentExpressableSupplier.get();
|
||||||
if ( inferredMapping != null ) {
|
if ( inferredMapping != null ) {
|
||||||
if ( inferredMapping instanceof PluralAttributeMapping ) {
|
if ( inferredMapping instanceof PluralAttributeMapping ) {
|
||||||
return ( (PluralAttributeMapping) inferredMapping ).getElementDescriptor();
|
return ( (PluralAttributeMapping) inferredMapping ).getElementDescriptor();
|
||||||
|
@ -4374,7 +4367,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( parameterSqmType instanceof SqmPath ) {
|
if ( parameterSqmType instanceof SqmPath ) {
|
||||||
final SqmPath sqmPath = (SqmPath) parameterSqmType;
|
final SqmPath<?> sqmPath = (SqmPath<?>) parameterSqmType;
|
||||||
final NavigablePath navigablePath = sqmPath.getNavigablePath();
|
final NavigablePath navigablePath = sqmPath.getNavigablePath();
|
||||||
if ( navigablePath.getParent() != null ) {
|
if ( navigablePath.getParent() != null ) {
|
||||||
final TableGroup tableGroup = getFromClauseAccess().getTableGroup( navigablePath.getParent() );
|
final TableGroup tableGroup = getFromClauseAccess().getTableGroup( navigablePath.getParent() );
|
||||||
|
@ -4415,13 +4408,13 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
throw new ConversionException( "Could not determine ValueMapping for SqmParameter: " + sqmParameter );
|
throw new ConversionException( "Could not determine ValueMapping for SqmParameter: " + sqmParameter );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final Stack<Supplier<MappingModelExpressable>> inferrableTypeAccessStack = new StandardStack<>(
|
protected final Stack<Supplier<MappingModelExpressable<?>>> inferrableTypeAccessStack = new StandardStack<>(
|
||||||
() -> null
|
() -> null
|
||||||
);
|
);
|
||||||
|
|
||||||
private void resolveSqmParameter(
|
private void resolveSqmParameter(
|
||||||
SqmParameter expression,
|
SqmParameter<?> expression,
|
||||||
MappingModelExpressable valueMapping,
|
MappingModelExpressable<?> valueMapping,
|
||||||
BiConsumer<Integer,JdbcParameter> jdbcParameterConsumer) {
|
BiConsumer<Integer,JdbcParameter> jdbcParameterConsumer) {
|
||||||
sqmParameterMappingModelTypes.put( expression, valueMapping );
|
sqmParameterMappingModelTypes.put( expression, valueMapping );
|
||||||
final Bindable bindable;
|
final Bindable bindable;
|
||||||
|
@ -4608,8 +4601,8 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object visitBinaryArithmeticExpression(SqmBinaryArithmetic<?> expression) {
|
public Object visitBinaryArithmeticExpression(SqmBinaryArithmetic<?> expression) {
|
||||||
SqmExpression leftOperand = expression.getLeftHandOperand();
|
SqmExpression<?> leftOperand = expression.getLeftHandOperand();
|
||||||
SqmExpression rightOperand = expression.getRightHandOperand();
|
SqmExpression<?> rightOperand = expression.getRightHandOperand();
|
||||||
|
|
||||||
boolean durationToRight = TypeConfiguration.isDuration( rightOperand.getNodeType() );
|
boolean durationToRight = TypeConfiguration.isDuration( rightOperand.getNodeType() );
|
||||||
TypeConfiguration typeConfiguration = getCreationContext().getDomainModel().getTypeConfiguration();
|
TypeConfiguration typeConfiguration = getCreationContext().getDomainModel().getTypeConfiguration();
|
||||||
|
@ -4707,10 +4700,10 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
adjustedTimestamp = toSqlExpression( expression.getLeftHandOperand().accept( this ) );
|
adjustedTimestamp = toSqlExpression( expression.getLeftHandOperand().accept( this ) );
|
||||||
JdbcMappingContainer type = adjustedTimestamp.getExpressionType();
|
JdbcMappingContainer type = adjustedTimestamp.getExpressionType();
|
||||||
if ( type instanceof SqmExpressable ) {
|
if ( type instanceof SqmExpressable ) {
|
||||||
adjustedTimestampType = (SqmExpressable) type;
|
adjustedTimestampType = (SqmExpressable<?>) type;
|
||||||
}
|
}
|
||||||
else if (type instanceof AttributeMapping ) {
|
else if (type instanceof AttributeMapping ) {
|
||||||
adjustedTimestampType = (SqmExpressable) ( (AttributeMapping) type ).getMappedType();
|
adjustedTimestampType = (SqmExpressable<?>) ( (AttributeMapping) type ).getMappedType();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// else we know it has not been transformed
|
// else we know it has not been transformed
|
||||||
|
@ -4758,7 +4751,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object transformDatetimeArithmetic(SqmBinaryArithmetic expression) {
|
private Object transformDatetimeArithmetic(SqmBinaryArithmetic<?> expression) {
|
||||||
BinaryArithmeticOperator operator = expression.getOperator();
|
BinaryArithmeticOperator operator = expression.getOperator();
|
||||||
|
|
||||||
// the only kind of algebra we know how to
|
// the only kind of algebra we know how to
|
||||||
|
@ -5055,7 +5048,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
@Override
|
@Override
|
||||||
public CaseSimpleExpression visitSimpleCaseExpression(SqmCaseSimple<?, ?> expression) {
|
public CaseSimpleExpression visitSimpleCaseExpression(SqmCaseSimple<?, ?> expression) {
|
||||||
final List<CaseSimpleExpression.WhenFragment> whenFragments = new ArrayList<>( expression.getWhenFragments().size() );
|
final List<CaseSimpleExpression.WhenFragment> whenFragments = new ArrayList<>( expression.getWhenFragments().size() );
|
||||||
final Supplier<MappingModelExpressable> inferenceSupplier = inferrableTypeAccessStack.getCurrent();
|
final Supplier<MappingModelExpressable<?>> inferenceSupplier = inferrableTypeAccessStack.getCurrent();
|
||||||
inferrableTypeAccessStack.push(
|
inferrableTypeAccessStack.push(
|
||||||
() -> {
|
() -> {
|
||||||
for ( SqmCaseSimple.WhenFragment<?, ?> whenFragment : expression.getWhenFragments() ) {
|
for ( SqmCaseSimple.WhenFragment<?, ?> whenFragment : expression.getWhenFragments() ) {
|
||||||
|
@ -5113,7 +5106,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
@Override
|
@Override
|
||||||
public CaseSearchedExpression visitSearchedCaseExpression(SqmCaseSearched<?> expression) {
|
public CaseSearchedExpression visitSearchedCaseExpression(SqmCaseSearched<?> expression) {
|
||||||
final List<CaseSearchedExpression.WhenFragment> whenFragments = new ArrayList<>( expression.getWhenFragments().size() );
|
final List<CaseSearchedExpression.WhenFragment> whenFragments = new ArrayList<>( expression.getWhenFragments().size() );
|
||||||
final Supplier<MappingModelExpressable> inferenceSupplier = inferrableTypeAccessStack.getCurrent();
|
final Supplier<MappingModelExpressable<?>> inferenceSupplier = inferrableTypeAccessStack.getCurrent();
|
||||||
MappingModelExpressable<?> resolved = determineCurrentExpressable( expression );
|
MappingModelExpressable<?> resolved = determineCurrentExpressable( expression );
|
||||||
|
|
||||||
Expression otherwise = null;
|
Expression otherwise = null;
|
||||||
|
@ -5161,39 +5154,35 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private <X> X visitWithLenientInferredType(SqmExpression<?> expression, SqmExpression<?> inferred) {
|
// private <X> X visitWithLenientInferredType(SqmExpression<?> expression, SqmExpression<?> inferred) {
|
||||||
inferrableTypeAccessStack.push(
|
// inferrableTypeAccessStack.push(
|
||||||
() -> {
|
// () -> {
|
||||||
MappingModelExpressable<?> definedType = creationContext
|
// MappingModelExpressable<?> definedType = creationContext
|
||||||
.getDomainModel()
|
// .getDomainModel()
|
||||||
.resolveMappingExpressable(
|
// .resolveMappingExpressable(
|
||||||
expression.getNodeType(),
|
// expression.getNodeType(),
|
||||||
getFromClauseIndex()::findTableGroup
|
// getFromClauseIndex()::findTableGroup
|
||||||
);
|
// );
|
||||||
if ( definedType != null ) {
|
// if ( definedType != null ) {
|
||||||
return definedType;
|
// return definedType;
|
||||||
}
|
// }
|
||||||
definedType = creationContext
|
// definedType = creationContext
|
||||||
.getDomainModel()
|
// .getDomainModel()
|
||||||
.lenientlyResolveMappingExpressable(
|
// .lenientlyResolveMappingExpressable(
|
||||||
inferred.getNodeType(),
|
// inferred.getNodeType(),
|
||||||
getFromClauseIndex()::findTableGroup
|
// getFromClauseIndex()::findTableGroup
|
||||||
);
|
// );
|
||||||
if ( definedType != null ) {
|
// return definedType;
|
||||||
return definedType;
|
// }
|
||||||
}
|
// );
|
||||||
|
//
|
||||||
return null;
|
// try {
|
||||||
}
|
// return (X) expression.accept( this );
|
||||||
);
|
// }
|
||||||
|
// finally {
|
||||||
try {
|
// inferrableTypeAccessStack.pop();
|
||||||
return (X) expression.accept( this );
|
// }
|
||||||
}
|
// }
|
||||||
finally {
|
|
||||||
inferrableTypeAccessStack.pop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object visitAny(SqmAny<?> sqmAny) {
|
public Object visitAny(SqmAny<?> sqmAny) {
|
||||||
|
@ -5255,7 +5244,8 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
final BasicValuedMapping inferrableType = (BasicValuedMapping) inferrableTypeAccessStack.getCurrent().get();
|
final BasicValuedMapping inferrableType = (BasicValuedMapping) inferrableTypeAccessStack.getCurrent().get();
|
||||||
if ( inferrableType instanceof ConvertibleModelPart ) {
|
if ( inferrableType instanceof ConvertibleModelPart ) {
|
||||||
final ConvertibleModelPart inferredPart = (ConvertibleModelPart) inferrableType;
|
final ConvertibleModelPart inferredPart = (ConvertibleModelPart) inferrableType;
|
||||||
final BasicValueConverter valueConverter = inferredPart.getValueConverter();
|
@SuppressWarnings("unchecked")
|
||||||
|
final BasicValueConverter<Enum<?>,?> valueConverter = inferredPart.getValueConverter();
|
||||||
final Object jdbcValue = valueConverter.toRelationalValue( sqmEnumLiteral.getEnumValue() );
|
final Object jdbcValue = valueConverter.toRelationalValue( sqmEnumLiteral.getEnumValue() );
|
||||||
return new QueryLiteral<>( jdbcValue, inferredPart );
|
return new QueryLiteral<>( jdbcValue, inferredPart );
|
||||||
}
|
}
|
||||||
|
@ -5312,8 +5302,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
() -> ( (EntityCollectionPart) pluralAttributeMapping.getElementDescriptor() ).getKeyTargetMatchPart() );
|
() -> ( (EntityCollectionPart) pluralAttributeMapping.getElementDescriptor() ).getKeyTargetMatchPart() );
|
||||||
}
|
}
|
||||||
else if ( pluralAttributeMapping.getElementDescriptor() instanceof EmbeddedCollectionPart ) {
|
else if ( pluralAttributeMapping.getElementDescriptor() instanceof EmbeddedCollectionPart ) {
|
||||||
inferrableTypeAccessStack.push(
|
inferrableTypeAccessStack.push(pluralAttributeMapping::getElementDescriptor);
|
||||||
() -> pluralAttributeMapping.getElementDescriptor() );
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
inferrableTypeAccessStack.push( () -> pluralAttributeMapping );
|
inferrableTypeAccessStack.push( () -> pluralAttributeMapping );
|
||||||
|
@ -5722,7 +5711,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InSubQueryPredicate visitInSubQueryPredicate(SqmInSubQueryPredicate predicate) {
|
public InSubQueryPredicate visitInSubQueryPredicate(SqmInSubQueryPredicate<?> predicate) {
|
||||||
return new InSubQueryPredicate(
|
return new InSubQueryPredicate(
|
||||||
visitWithInferredType( predicate.getTestExpression(), predicate.getSubQueryExpression() ),
|
visitWithInferredType( predicate.getTestExpression(), predicate.getSubQueryExpression() ),
|
||||||
visitWithInferredType( predicate.getSubQueryExpression(), predicate.getTestExpression() ),
|
visitWithInferredType( predicate.getSubQueryExpression(), predicate.getTestExpression() ),
|
||||||
|
@ -5865,16 +5854,16 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final TableGroup existingJoinedGroup = fromClauseIndex.findTableGroup( fetchablePath );
|
// final TableGroup existingJoinedGroup = fromClauseIndex.findTableGroup( fetchablePath );
|
||||||
if ( existingJoinedGroup != null ) {
|
// if ( existingJoinedGroup != null ) {
|
||||||
// we can use this to trigger the fetch from the joined group.
|
// we can use this to trigger the fetch from the joined group.
|
||||||
|
|
||||||
// todo (6.0) : do we want to do this though?
|
// todo (6.0) : do we want to do this though?
|
||||||
// On the positive side it would allow EntityGraph to use the existing TableGroup. But that ties in
|
// On the positive side it would allow EntityGraph to use the existing TableGroup. But that ties in
|
||||||
// to the discussion above regarding how to handle eager and EntityGraph (JOIN versus SELECT).
|
// to the discussion above regarding how to handle eager and EntityGraph (JOIN versus SELECT).
|
||||||
// Can be problematic if the existing one is restricted
|
// Can be problematic if the existing one is restricted
|
||||||
//fetchTiming = FetchTiming.IMMEDIATE;
|
// fetchTiming = FetchTiming.IMMEDIATE;
|
||||||
}
|
// }
|
||||||
|
|
||||||
// lastly, account for any app-defined max-fetch-depth
|
// lastly, account for any app-defined max-fetch-depth
|
||||||
final Integer maxDepth = getCreationContext().getMaximumFetchDepth();
|
final Integer maxDepth = getCreationContext().getMaximumFetchDepth();
|
||||||
|
@ -6147,10 +6136,6 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
return delegate.resolveSqlSelection( expression, javaTypeDescriptor, typeConfiguration );
|
return delegate.resolveSqlSelection( expression, javaTypeDescriptor, typeConfiguration );
|
||||||
}
|
}
|
||||||
|
|
||||||
public SqmAliasedNodeCollector getSqmAliasedNodeCollector() {
|
|
||||||
return sqmAliasedNodeCollector;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSqmAliasedNodeCollector(SqmAliasedNodeCollector sqmAliasedNodeCollector) {
|
public void setSqmAliasedNodeCollector(SqmAliasedNodeCollector sqmAliasedNodeCollector) {
|
||||||
this.sqmAliasedNodeCollector = sqmAliasedNodeCollector;
|
this.sqmAliasedNodeCollector = sqmAliasedNodeCollector;
|
||||||
}
|
}
|
||||||
|
@ -6161,6 +6146,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
private final List<SqlSelection>[] sqlSelectionsForSqmSelection;
|
private final List<SqlSelection>[] sqlSelectionsForSqmSelection;
|
||||||
private int index = -1;
|
private int index = -1;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public SqmAliasedNodePositionTracker(SqlExpressionResolver delegate, List<? extends SqmAliasedNode<?>> selections) {
|
public SqmAliasedNodePositionTracker(SqlExpressionResolver delegate, List<? extends SqmAliasedNode<?>> selections) {
|
||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
this.sqlSelectionsForSqmSelection = new List[countIndividualSelections( selections )];
|
this.sqlSelectionsForSqmSelection = new List[countIndividualSelections( selections )];
|
||||||
|
@ -6211,20 +6197,18 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Expression> expandSelfRenderingFunctionMultiValueParameter(SqmParameter sqmParameter) {
|
public List<Expression> expandSelfRenderingFunctionMultiValueParameter(SqmParameter<?> sqmParameter) {
|
||||||
assert sqmParameter.allowMultiValuedBinding();
|
assert sqmParameter.allowMultiValuedBinding();
|
||||||
final QueryParameterImplementor<?> domainParam = domainParameterXref.getQueryParameter(
|
final QueryParameterImplementor<?> domainParam = domainParameterXref.getQueryParameter( sqmParameter );
|
||||||
sqmParameter );
|
final QueryParameterBinding<?> domainParamBinding = domainParameterBindings.getBinding( domainParam );
|
||||||
final QueryParameterBinding domainParamBinding = domainParameterBindings.getBinding(
|
|
||||||
domainParam );
|
|
||||||
|
|
||||||
final Collection bindValues = domainParamBinding.getBindValues();
|
final Collection<?> bindValues = domainParamBinding.getBindValues();
|
||||||
final int bindValuesSize = bindValues.size();
|
final int bindValuesSize = bindValues.size();
|
||||||
final List<Expression> result = new ArrayList<>( bindValuesSize );
|
final List<Expression> result = new ArrayList<>( bindValuesSize );
|
||||||
|
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
for ( int i = 0; i < bindValuesSize; i++ ) {
|
for ( int i = 0; i < bindValuesSize; i++ ) {
|
||||||
final SqmParameter sqmParamToConsume;
|
final SqmParameter<?> sqmParamToConsume;
|
||||||
// for each bind value create an "expansion"
|
// for each bind value create an "expansion"
|
||||||
if ( first ) {
|
if ( first ) {
|
||||||
sqmParamToConsume = sqmParameter;
|
sqmParamToConsume = sqmParameter;
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class FakeSqmToSqlAstConverter extends BaseSemanticQueryWalker implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Expression> expandSelfRenderingFunctionMultiValueParameter(SqmParameter sqmParameter) {
|
public List<Expression> expandSelfRenderingFunctionMultiValueParameter(SqmParameter<?> sqmParameter) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,6 @@ import org.hibernate.sql.ast.tree.expression.Expression;
|
||||||
public interface SqmToSqlAstConverter extends SemanticQueryWalker<Object>, SqlAstCreationState {
|
public interface SqmToSqlAstConverter extends SemanticQueryWalker<Object>, SqlAstCreationState {
|
||||||
Stack<Clause> getCurrentClauseStack();
|
Stack<Clause> getCurrentClauseStack();
|
||||||
|
|
||||||
List<Expression> expandSelfRenderingFunctionMultiValueParameter(SqmParameter sqmParameter);
|
List<Expression> expandSelfRenderingFunctionMultiValueParameter(SqmParameter<?> sqmParameter);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,8 @@ package org.hibernate.query.sqm.sql;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
import org.hibernate.metamodel.mapping.MappingModelExpressable;
|
import org.hibernate.metamodel.mapping.MappingModelExpressable;
|
||||||
import org.hibernate.query.sqm.spi.SqmParameterMappingModelResolutionAccess;
|
|
||||||
import org.hibernate.query.sqm.tree.expression.SqmParameter;
|
import org.hibernate.query.sqm.tree.expression.SqmParameter;
|
||||||
import org.hibernate.sql.ast.spi.FromClauseAccess;
|
import org.hibernate.sql.ast.spi.FromClauseAccess;
|
||||||
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
||||||
|
@ -27,6 +25,6 @@ public interface SqmTranslation<T extends Statement> {
|
||||||
T getSqlAst();
|
T getSqlAst();
|
||||||
SqlExpressionResolver getSqlExpressionResolver();
|
SqlExpressionResolver getSqlExpressionResolver();
|
||||||
FromClauseAccess getFromClauseAccess();
|
FromClauseAccess getFromClauseAccess();
|
||||||
Map<SqmParameter, List<List<JdbcParameter>>> getJdbcParamsBySqmParam();
|
Map<SqmParameter<?>, List<List<JdbcParameter>>> getJdbcParamsBySqmParam();
|
||||||
Map<SqmParameter,MappingModelExpressable> getSqmParameterMappingModelTypeResolutions();
|
Map<SqmParameter<?>, MappingModelExpressable<?>> getSqmParameterMappingModelTypeResolutions();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,15 +22,15 @@ import org.hibernate.sql.ast.tree.expression.JdbcParameter;
|
||||||
public class StandardSqmTranslation<T extends Statement> implements SqmTranslation<T> {
|
public class StandardSqmTranslation<T extends Statement> implements SqmTranslation<T> {
|
||||||
|
|
||||||
private final T sqlAst;
|
private final T sqlAst;
|
||||||
private final Map<SqmParameter, List<List<JdbcParameter>>> jdbcParamMap;
|
private final Map<SqmParameter<?>, List<List<JdbcParameter>>> jdbcParamMap;
|
||||||
private final Map<SqmParameter, MappingModelExpressable> parameterMappingModelTypeMap;
|
private final Map<SqmParameter<?>, MappingModelExpressable<?>> parameterMappingModelTypeMap;
|
||||||
private final SqlExpressionResolver sqlExpressionResolver;
|
private final SqlExpressionResolver sqlExpressionResolver;
|
||||||
private final FromClauseAccess fromClauseAccess;
|
private final FromClauseAccess fromClauseAccess;
|
||||||
|
|
||||||
public StandardSqmTranslation(
|
public StandardSqmTranslation(
|
||||||
T sqlAst,
|
T sqlAst,
|
||||||
Map<SqmParameter, List<List<JdbcParameter>>> jdbcParamMap,
|
Map<SqmParameter<?>, List<List<JdbcParameter>>> jdbcParamMap,
|
||||||
Map<SqmParameter, MappingModelExpressable> parameterMappingModelTypeMap,
|
Map<SqmParameter<?>, MappingModelExpressable<?>> parameterMappingModelTypeMap,
|
||||||
SqlExpressionResolver sqlExpressionResolver,
|
SqlExpressionResolver sqlExpressionResolver,
|
||||||
FromClauseAccess fromClauseAccess) {
|
FromClauseAccess fromClauseAccess) {
|
||||||
this.sqlAst = sqlAst;
|
this.sqlAst = sqlAst;
|
||||||
|
@ -46,12 +46,12 @@ public class StandardSqmTranslation<T extends Statement> implements SqmTranslati
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<SqmParameter, List<List<JdbcParameter>>> getJdbcParamsBySqmParam() {
|
public Map<SqmParameter<?>, List<List<JdbcParameter>>> getJdbcParamsBySqmParam() {
|
||||||
return jdbcParamMap;
|
return jdbcParamMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<SqmParameter, MappingModelExpressable> getSqmParameterMappingModelTypeResolutions() {
|
public Map<SqmParameter<?>, MappingModelExpressable<?>> getSqmParameterMappingModelTypeResolutions() {
|
||||||
return parameterMappingModelTypeMap;
|
return parameterMappingModelTypeMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ public interface FromClauseAccess {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a TableGroup under the given `navigablePath`. Logs a message
|
* Register a TableGroup under the given `navigablePath`. Logs a message
|
||||||
* if thhis registration over-writes an existing one.
|
* if this registration over-writes an existing one.
|
||||||
*/
|
*/
|
||||||
void registerTableGroup(NavigablePath navigablePath, TableGroup tableGroup);
|
void registerTableGroup(NavigablePath navigablePath, TableGroup tableGroup);
|
||||||
|
|
||||||
|
|
|
@ -19,5 +19,5 @@ public interface FunctionExpression extends Expression {
|
||||||
|
|
||||||
String getFunctionName();
|
String getFunctionName();
|
||||||
|
|
||||||
List<SqlAstNode> getArguments();
|
List<? extends SqlAstNode> getArguments();
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,9 +59,9 @@ public class SubqueryTest extends BaseSessionFactoryFunctionalTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(
|
public void render(
|
||||||
SqlAppender sqlAppender, List<SqlAstNode> sqlAstArguments, SqlAstTranslator<?> walker) {
|
SqlAppender sqlAppender, List<? extends SqlAstNode> sqlAstArguments, SqlAstTranslator<?> walker) {
|
||||||
sqlAstArguments.get( 0 ).accept( walker );
|
sqlAstArguments.get( 0 ).accept( walker );
|
||||||
sqlAppender.appendSql( " limit " + ( (QueryLiteral) sqlAstArguments.get( 1 ) ).getLiteralValue() );
|
sqlAppender.appendSql( " limit " + ( (QueryLiteral<?>) sqlAstArguments.get( 1 ) ).getLiteralValue() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue