use of org.hibernate.sql.ast.tree.expression.CaseSimpleExpression in project hibernate-orm by hibernate.
the class SybaseAnywhereSqlAstTranslator 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 SybaseASESqlAstTranslator 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 AbstractSqlAstTranslator method areAllResultsParameters.
protected boolean areAllResultsParameters(CaseSimpleExpression caseSimpleExpression) {
final List<CaseSimpleExpression.WhenFragment> whenFragments = caseSimpleExpression.getWhenFragments();
final Expression firstResult = whenFragments.get(0).getResult();
if (isParameter(firstResult)) {
for (int i = 1; i < whenFragments.size(); i++) {
if (!isParameter(whenFragments.get(i).getResult())) {
return false;
}
}
return true;
}
return false;
}
use of org.hibernate.sql.ast.tree.expression.CaseSimpleExpression in project hibernate-orm by hibernate.
the class AbstractSqlAstTranslator method visitAnsiCaseSimpleExpression.
protected void visitAnsiCaseSimpleExpression(CaseSimpleExpression caseSimpleExpression, Consumer<Expression> resultRenderer) {
appendSql("case ");
final SqlAstNodeRenderingMode original = this.parameterRenderingMode;
if (original != SqlAstNodeRenderingMode.INLINE_ALL_PARAMETERS) {
this.parameterRenderingMode = SqlAstNodeRenderingMode.DEFAULT;
}
caseSimpleExpression.getFixture().accept(this);
for (CaseSimpleExpression.WhenFragment whenFragment : caseSimpleExpression.getWhenFragments()) {
if (original != SqlAstNodeRenderingMode.INLINE_ALL_PARAMETERS) {
this.parameterRenderingMode = SqlAstNodeRenderingMode.DEFAULT;
}
appendSql(" when ");
whenFragment.getCheckValue().accept(this);
this.parameterRenderingMode = original;
appendSql(" then ");
resultRenderer.accept(whenFragment.getResult());
}
this.parameterRenderingMode = original;
final Expression otherwise = caseSimpleExpression.getOtherwise();
if (otherwise != null) {
appendSql(" else ");
resultRenderer.accept(otherwise);
}
appendSql(" end");
}
Aggregations