use of org.hibernate.sql.ast.tree.expression.CaseSimpleExpression in project hibernate-orm by hibernate.
the class DB2SqlAstTranslator method visitAnsiCaseSimpleExpression.
@Override
protected void visitAnsiCaseSimpleExpression(CaseSimpleExpression caseSimpleExpression, Consumer<Expression> resultRenderer) {
if (getParameterRenderingMode() == SqlAstNodeRenderingMode.DEFAULT && areAllResultsParameters(caseSimpleExpression)) {
final List<CaseSimpleExpression.WhenFragment> whenFragments = caseSimpleExpression.getWhenFragments();
final Expression firstResult = whenFragments.get(0).getResult();
super.visitAnsiCaseSimpleExpression(caseSimpleExpression, e -> {
if (e == firstResult) {
renderCasted(e);
} else {
resultRenderer.accept(e);
}
});
} else {
super.visitAnsiCaseSimpleExpression(caseSimpleExpression, resultRenderer);
}
}
use of org.hibernate.sql.ast.tree.expression.CaseSimpleExpression in project hibernate-orm by hibernate.
the class SybaseSqlAstTranslator method visitAnsiCaseSimpleExpression.
@Override
protected void visitAnsiCaseSimpleExpression(CaseSimpleExpression caseSimpleExpression, Consumer<Expression> resultRenderer) {
if (getParameterRenderingMode() == SqlAstNodeRenderingMode.DEFAULT && areAllResultsParameters(caseSimpleExpression)) {
final List<CaseSimpleExpression.WhenFragment> whenFragments = caseSimpleExpression.getWhenFragments();
final Expression firstResult = whenFragments.get(0).getResult();
super.visitAnsiCaseSimpleExpression(caseSimpleExpression, e -> {
if (e == firstResult) {
renderCasted(e);
} else {
resultRenderer.accept(e);
}
});
} else {
super.visitAnsiCaseSimpleExpression(caseSimpleExpression, resultRenderer);
}
}
use of org.hibernate.sql.ast.tree.expression.CaseSimpleExpression in project hibernate-orm by hibernate.
the class BaseSqmToSqlAstConverter method visitSimpleCaseExpression.
@Override
public CaseSimpleExpression visitSimpleCaseExpression(SqmCaseSimple<?, ?> expression) {
final List<CaseSimpleExpression.WhenFragment> whenFragments = new ArrayList<>(expression.getWhenFragments().size());
final Supplier<MappingModelExpressible<?>> inferenceSupplier = inferrableTypeAccessStack.getCurrent();
inferrableTypeAccessStack.push(() -> {
for (SqmCaseSimple.WhenFragment<?, ?> whenFragment : expression.getWhenFragments()) {
final MappingModelExpressible<?> resolved = determineCurrentExpressible(whenFragment.getCheckValue());
if (resolved != null) {
return resolved;
}
}
return null;
});
final Expression fixture = (Expression) expression.getFixture().accept(this);
final MappingModelExpressible<?> fixtureType = (MappingModelExpressible<?>) fixture.getExpressionType();
inferrableTypeAccessStack.pop();
MappingModelExpressible<?> resolved = determineCurrentExpressible(expression);
Expression otherwise = null;
for (SqmCaseSimple.WhenFragment<?, ?> whenFragment : expression.getWhenFragments()) {
inferrableTypeAccessStack.push(() -> fixtureType);
final Expression checkValue = (Expression) whenFragment.getCheckValue().accept(this);
inferrableTypeAccessStack.pop();
final MappingModelExpressible<?> alreadyKnown = resolved;
inferrableTypeAccessStack.push(() -> alreadyKnown == null && inferenceSupplier != null ? inferenceSupplier.get() : alreadyKnown);
final Expression resultExpression = (Expression) whenFragment.getResult().accept(this);
inferrableTypeAccessStack.pop();
resolved = (MappingModelExpressible<?>) highestPrecedence(resolved, resultExpression.getExpressionType());
whenFragments.add(new CaseSimpleExpression.WhenFragment(checkValue, resultExpression));
}
if (expression.getOtherwise() != null) {
final MappingModelExpressible<?> alreadyKnown = resolved;
inferrableTypeAccessStack.push(() -> alreadyKnown == null && inferenceSupplier != null ? inferenceSupplier.get() : alreadyKnown);
otherwise = (Expression) expression.getOtherwise().accept(this);
inferrableTypeAccessStack.pop();
resolved = (MappingModelExpressible<?>) highestPrecedence(resolved, otherwise.getExpressionType());
}
return new CaseSimpleExpression(resolved, fixture, whenFragments, otherwise);
}
use of org.hibernate.sql.ast.tree.expression.CaseSimpleExpression in project hibernate-orm by hibernate.
the class HSQLSqlAstTranslator method visitAnsiCaseSimpleExpression.
@Override
protected void visitAnsiCaseSimpleExpression(CaseSimpleExpression caseSimpleExpression, Consumer<Expression> resultRenderer) {
if (getParameterRenderingMode() == SqlAstNodeRenderingMode.DEFAULT && areAllResultsParameters(caseSimpleExpression)) {
final List<CaseSimpleExpression.WhenFragment> whenFragments = caseSimpleExpression.getWhenFragments();
final Expression firstResult = whenFragments.get(0).getResult();
super.visitAnsiCaseSimpleExpression(caseSimpleExpression, e -> {
if (e == firstResult) {
renderCasted(e);
} else {
resultRenderer.accept(e);
}
});
} else {
super.visitAnsiCaseSimpleExpression(caseSimpleExpression, resultRenderer);
}
}
use of org.hibernate.sql.ast.tree.expression.CaseSimpleExpression in project hibernate-orm by hibernate.
the class DerbySqlAstTranslator method visitAnsiCaseSimpleExpression.
@Override
protected void visitAnsiCaseSimpleExpression(CaseSimpleExpression caseSimpleExpression, Consumer<Expression> resultRenderer) {
if (getParameterRenderingMode() == SqlAstNodeRenderingMode.DEFAULT && areAllResultsParameters(caseSimpleExpression)) {
final List<CaseSimpleExpression.WhenFragment> whenFragments = caseSimpleExpression.getWhenFragments();
final Expression firstResult = whenFragments.get(0).getResult();
super.visitAnsiCaseSimpleExpression(caseSimpleExpression, e -> {
if (e == firstResult) {
renderCasted(e);
} else {
resultRenderer.accept(e);
}
});
} else {
super.visitAnsiCaseSimpleExpression(caseSimpleExpression, resultRenderer);
}
}
Aggregations