Edit: Ack, my apologies, misread your post. Not actually the same issue, although the parameters are being placed in the code, using Hibernate 3.2 and the code mentioned below.
I have run into the same problem as mentioned, and attempted to work around it by creating a custom "if" function in my Dialect.
The problem with this approach is that SQLFunctions only allow their return type to be static or changed in reference to the first parameter, which is counter intuitive for an if (or ifnull) function, as it would mean specifying the then/else clauses prior to the condition.
Instead I found the only suitable approach was to create a batch of functions with differing return types, named "ifint", "ifstring" etc, but this is an ugly work around and pollutes my HQL with a bucket load of proprietary function names.
If you need an immediate solution, I'd advise creating a subtype of your Dialect (in my case MySQL), and registering a selection of if functions, as follows:
Code:
public class MySQL5CustomDialect extends MySQL5InnoDBDialect {
public MySQL5CustomDialect () {
registerFunction("ifdouble", new SQLFunctionTemplate(
org.hibernate.Hibernate.DOUBLE, "if(?1, ?2 ?3)"));
registerFunction("ifint", new SQLFunctionTemplate(
org.hibernate.Hibernate.INTEGER, "if(?1, ?2 ?3)"));
registerFunction("ifstring", new SQLFunctionTemplate(
org.hibernate.Hibernate.STRING, "if(?1, ?2 ?3)"));
}
}