use of org.hibernate.query.sqm.produce.function.internal.PatternRenderer in project hibernate-orm by hibernate.
the class CastingConcatFunction method renderAsString.
private void renderAsString(SqlAppender sqlAppender, SqlAstTranslator<?> translator, Expression expression) {
final JdbcMapping sourceMapping = expression.getExpressionType().getJdbcMappings().get(0);
// No need to cast if we already have a string
if (sourceMapping.getCastType() == CastType.STRING) {
translator.render(expression, argumentRenderingMode);
} else {
final String cast = dialect.castPattern(sourceMapping.getCastType(), CastType.STRING);
new PatternRenderer(cast.replace("?2", concatArgumentCastType), argumentRenderingMode).render(sqlAppender, Collections.singletonList(expression), translator);
}
}
use of org.hibernate.query.sqm.produce.function.internal.PatternRenderer in project hibernate-orm by hibernate.
the class TimestampaddFunction method patternRenderer.
PatternRenderer patternRenderer(TemporalUnit unit, Expression interval, Expression to) {
TemporalType temporalType = getSqlTemporalType(to.getExpressionType());
IntervalType intervalType = getSqlIntervalType(interval.getExpressionType().getJdbcMappings().get(0));
return new PatternRenderer(dialect.timestampaddPattern(unit, temporalType, intervalType));
}
use of org.hibernate.query.sqm.produce.function.internal.PatternRenderer in project hibernate-orm by hibernate.
the class TimestampdiffFunction method patternRenderer.
private PatternRenderer patternRenderer(TemporalUnit unit, Expression from, Expression to) {
TemporalType lhsTemporalType = getSqlTemporalType(from.getExpressionType());
TemporalType rhsTemporalType = getSqlTemporalType(to.getExpressionType());
return new PatternRenderer(dialect.timestampdiffPattern(unit, lhsTemporalType, rhsTemporalType));
}
use of org.hibernate.query.sqm.produce.function.internal.PatternRenderer in project hibernate-orm by hibernate.
the class TrimFunction method render.
@Override
public void render(SqlAppender sqlAppender, List<? extends SqlAstNode> sqlAstArguments, SqlAstTranslator<?> walker) {
final TrimSpec specification = ((TrimSpecification) sqlAstArguments.get(0)).getSpecification();
final Object trimCharacter = ((Literal) sqlAstArguments.get(1)).getLiteralValue();
final Expression sourceExpr = (Expression) sqlAstArguments.get(2);
String trim = dialect.trimPattern(specification, (char) trimCharacter);
new PatternRenderer(trim).render(sqlAppender, Collections.singletonList(sourceExpr), walker);
}
use of org.hibernate.query.sqm.produce.function.internal.PatternRenderer in project hibernate-orm by hibernate.
the class CountFunction method renderCastedArgument.
private boolean renderCastedArgument(SqlAppender sqlAppender, SqlAstTranslator<?> translator, Expression realArg) {
if (concatArgumentCastType == null) {
translator.render(realArg, defaultArgumentRenderingMode);
return true;
} else {
final JdbcMapping sourceMapping = realArg.getExpressionType().getJdbcMappings().get(0);
// No need to cast if we already have a string
if (sourceMapping.getCastType() == CastType.STRING) {
translator.render(realArg, defaultArgumentRenderingMode);
return false;
} else {
final String cast = dialect.castPattern(sourceMapping.getCastType(), CastType.STRING);
new PatternRenderer(cast.replace("?2", concatArgumentCastType)).render(sqlAppender, Collections.singletonList(realArg), translator);
return false;
}
}
}
Aggregations