NullnessLiteral cleanup

This commit is contained in:
Christian Beikov 2021-09-29 18:50:16 +02:00
parent 10e508dfe7
commit d5078456a2
4 changed files with 1 additions and 68 deletions

View File

@ -26,7 +26,6 @@ import org.hibernate.sql.ast.tree.expression.ExtractUnit;
import org.hibernate.sql.ast.tree.expression.Format;
import org.hibernate.sql.ast.tree.expression.JdbcLiteral;
import org.hibernate.sql.ast.tree.expression.JdbcParameter;
import org.hibernate.sql.ast.tree.expression.NullnessLiteral;
import org.hibernate.sql.ast.tree.expression.QueryLiteral;
import org.hibernate.sql.ast.tree.expression.SelfRenderingExpression;
import org.hibernate.sql.ast.tree.expression.SqlSelectionExpression;
@ -144,8 +143,6 @@ public interface SqlAstWalker {
void visitQueryLiteral(QueryLiteral queryLiteral);
void visitNullnessLiteral(NullnessLiteral nullnessLiteral);
void visitUnaryOperationExpression(UnaryOperation unaryOperationExpression);
void visitBooleanExpressionPredicate(BooleanExpressionPredicate booleanExpressionPredicate);

View File

@ -95,7 +95,6 @@ import org.hibernate.sql.ast.tree.expression.JdbcLiteral;
import org.hibernate.sql.ast.tree.expression.JdbcParameter;
import org.hibernate.sql.ast.tree.expression.Literal;
import org.hibernate.sql.ast.tree.expression.LiteralAsParameter;
import org.hibernate.sql.ast.tree.expression.NullnessLiteral;
import org.hibernate.sql.ast.tree.expression.QueryLiteral;
import org.hibernate.sql.ast.tree.expression.SelfRenderingExpression;
import org.hibernate.sql.ast.tree.expression.SqlSelectionExpression;
@ -3240,7 +3239,7 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
renderLiteral( literal, true );
}
}
else if ( expression instanceof NullnessLiteral || isParameter( expression ) ) {
else if ( isParameter( expression ) ) {
if ( parameterRenderingMode == SqlAstNodeRenderingMode.INLINE_PARAMETERS || parameterRenderingMode == SqlAstNodeRenderingMode.INLINE_ALL_PARAMETERS ) {
renderExpressionAsLiteral( expression, getJdbcParameterBindings() );
}
@ -4178,12 +4177,6 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
visitLiteral( queryLiteral );
}
@Override
public void visitNullnessLiteral(NullnessLiteral nullnessLiteral) {
// todo (6.0) : account for composite nulls?
appendSql( "null" );
}
private void visitLiteral(Literal literal) {
if ( literal.getLiteralValue() == null ) {
// todo : not sure we allow this "higher up"

View File

@ -30,7 +30,6 @@ import org.hibernate.sql.ast.tree.expression.Format;
import org.hibernate.sql.ast.tree.expression.FunctionExpression;
import org.hibernate.sql.ast.tree.expression.JdbcLiteral;
import org.hibernate.sql.ast.tree.expression.JdbcParameter;
import org.hibernate.sql.ast.tree.expression.NullnessLiteral;
import org.hibernate.sql.ast.tree.expression.QueryLiteral;
import org.hibernate.sql.ast.tree.expression.SelfRenderingExpression;
import org.hibernate.sql.ast.tree.expression.SqlSelectionExpression;
@ -331,10 +330,6 @@ class AggregateFunctionChecker implements SqlAstWalker {
public void visitQueryLiteral(QueryLiteral queryLiteral) {
}
@Override
public void visitNullnessLiteral(NullnessLiteral nullnessLiteral) {
}
@Override
public void visitSummarization(Summarization every) {
}

View File

@ -1,52 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.sql.ast.tree.expression;
import org.hibernate.metamodel.mapping.MappingModelExpressable;
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
import org.hibernate.sql.ast.SqlAstWalker;
import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.sql.results.graph.basic.BasicResult;
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
/**
* Assertion that the SQL state of a "mapping model expressable" is null
*/
public class NullnessLiteral implements Expression, DomainResultProducer<Boolean> {
private final MappingModelExpressable<?> valueMapping;
public NullnessLiteral(MappingModelExpressable<?> valueMapping) {
this.valueMapping = valueMapping;
}
@Override
public MappingModelExpressable<?> getExpressionType() {
return valueMapping;
}
@Override
public void accept(SqlAstWalker sqlTreeWalker) {
sqlTreeWalker.visitNullnessLiteral( this );
}
@Override
public DomainResult createDomainResult(
String resultVariable,
DomainResultCreationState creationState) {
final JavaTypeDescriptor javaTypeDescriptor = valueMapping.getJdbcMappings().get( 0 ).getJavaTypeDescriptor();
return new BasicResult(
creationState.getSqlAstCreationState().getSqlExpressionResolver().resolveSqlSelection(
this,
javaTypeDescriptor,
creationState.getSqlAstCreationState().getCreationContext().getDomainModel().getTypeConfiguration()
).getValuesArrayPosition(),
resultVariable,
javaTypeDescriptor
);
}
}