Search in sources :

Example 1 with SqmCastTarget

use of org.hibernate.query.sqm.tree.expression.SqmCastTarget in project hibernate-orm by hibernate.

the class SemanticQueryBuilder method visitCastTarget.

@Override
public SqmCastTarget<?> visitCastTarget(HqlParser.CastTargetContext castTargetContext) {
    final HqlParser.CastTargetTypeContext castTargetTypeContext = (HqlParser.CastTargetTypeContext) castTargetContext.getChild(0);
    final String targetName = castTargetTypeContext.fullTargetName;
    Long length = null;
    Integer precision = null;
    Integer scale = null;
    switch(castTargetTypeContext.getChildCount()) {
        case 6:
            scale = Integer.valueOf(castTargetTypeContext.getChild(4).getText());
        case 4:
            length = Long.valueOf(castTargetTypeContext.getChild(2).getText());
            precision = length.intValue();
            break;
    }
    return new SqmCastTarget<>((ReturnableType<?>) creationContext.getJpaMetamodel().getTypeConfiguration().resolveCastTargetType(targetName), // TODO: is there some way to interpret as length vs precision/scale here at this point?
    length, precision, scale, creationContext.getNodeBuilder());
}
Also used : BigInteger(java.math.BigInteger) SqmCastTarget(org.hibernate.query.sqm.tree.expression.SqmCastTarget) HqlParser(org.hibernate.grammars.hql.HqlParser)

Aggregations

BigInteger (java.math.BigInteger)1 HqlParser (org.hibernate.grammars.hql.HqlParser)1 SqmCastTarget (org.hibernate.query.sqm.tree.expression.SqmCastTarget)1