I’ve created a user defined function in hibernate called bitwiseAnd, and registered it in the dialect constructor as follows:
public SQLServerDialect() {
super();
registerFunction("bitwiseAnd", new SqlBitwiseFunction("bitwiseAnd", StandardBasicTypes.INTEGER));
}
I needed to do the same for Oracle as we support that too, and because they have different syntax’s with regards to bitwise operations. I was hoping to use this in the @DiscriminatorFormula, but it doesn’t seem to see the registered function. Is this possible, or does the discriminator formula only use native SQL?
Thanks,
R.
The javadoc of DiscriminatorFormula links to the javadoc of Formula, which contains the following:
So yes, the formula must be valid SQL, and not HQL.