Ha indeed, but unfortunately my need is to be able to use cast(xx as numeric)
in HQL because I want to be able to use the same string both for HQL and SQL.
I suspect that the solution to my problem will be to separate the execution paths for SQL and HQL. Once this is done, I can simply register a function in HQL to do any cast I want without hacking around (as proposed in Set precision in criteria BigInteger cast - #2 by beikov for example).