Search in sources :

Example 6 with PatternRenderer

use of org.hibernate.query.sqm.produce.function.internal.PatternRenderer in project hibernate-orm by hibernate.

the class CastFunction method render.

@Override
public void render(SqlAppender sqlAppender, List<? extends SqlAstNode> arguments, SqlAstTranslator<?> walker) {
    final Expression source = (Expression) arguments.get(0);
    final JdbcMapping sourceMapping = source.getExpressionType().getJdbcMappings().get(0);
    final CastType sourceType = getCastType(sourceMapping);
    final CastTarget castTarget = (CastTarget) arguments.get(1);
    final JdbcMapping targetJdbcMapping = castTarget.getExpressionType().getJdbcMappings().get(0);
    final CastType targetType = getCastType(targetJdbcMapping);
    String cast = dialect.castPattern(sourceType, targetType);
    new PatternRenderer(cast).render(sqlAppender, arguments, walker);
}
Also used : JdbcMapping(org.hibernate.metamodel.mapping.JdbcMapping) CastTarget(org.hibernate.sql.ast.tree.expression.CastTarget) Expression(org.hibernate.sql.ast.tree.expression.Expression) PatternRenderer(org.hibernate.query.sqm.produce.function.internal.PatternRenderer) CastType(org.hibernate.query.sqm.CastType)

Aggregations

PatternRenderer (org.hibernate.query.sqm.produce.function.internal.PatternRenderer)6 JdbcMapping (org.hibernate.metamodel.mapping.JdbcMapping)3 TemporalType (jakarta.persistence.TemporalType)2 Expression (org.hibernate.sql.ast.tree.expression.Expression)2 TypeConfiguration.getSqlTemporalType (org.hibernate.type.spi.TypeConfiguration.getSqlTemporalType)2 CastType (org.hibernate.query.sqm.CastType)1 IntervalType (org.hibernate.query.sqm.IntervalType)1 TrimSpec (org.hibernate.query.sqm.TrimSpec)1 CastTarget (org.hibernate.sql.ast.tree.expression.CastTarget)1 Literal (org.hibernate.sql.ast.tree.expression.Literal)1 TrimSpecification (org.hibernate.sql.ast.tree.expression.TrimSpecification)1 TypeConfiguration.getSqlIntervalType (org.hibernate.type.spi.TypeConfiguration.getSqlIntervalType)1