Using cast(xx as numeric) without precision

Hi,

Thank you for your help!

I tried adding such a DdlType:

    @Override
    public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
        super.contributeTypes(typeContributions, serviceRegistry);
        typeContributions.getTypeConfiguration().getDdlTypeRegistry().addDescriptor(
            new DdlTypeImpl(SqlTypes.NUMERIC, "numeric", this)
        );

I didn’t override getCastTypeName since its implementation already takes care of returning the value passed to the constructor when it does not contain $p or $s.

But I am still getting the following error:

Caused by: org.hibernate.HibernateException: unrecognized cast target type: numeric
	at org.hibernate.type.spi.TypeConfiguration.resolveCastTargetType(TypeConfiguration.java:371)
	at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitCastTarget(SemanticQueryBuilder.java:4338)
	at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitCastTarget(SemanticQueryBuilder.java:269)
	at org.hibernate.grammars.hql.HqlParser$CastTargetContext.accept(HqlParser.java:14369)
	at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitCastFunction(SemanticQueryBuilder.java:4315)
	at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitCastFunction(SemanticQueryBuilder.java:269)
...

According to the code it makes sense because it seems Hibernate is trying to find the type inside the basic type registry.

Once I am clearer about what I am trying to achieve (since there could be a lot of different ways of achieving the same objective), I will at least create a ticket yes :slight_smile: