I am struggling to find out how to migrate my code containing org.hibernate.dialect.function.SQLFunction.render method … to Hibernate 6
SessionFactoryImplementor d = this.entityManagerFactory.unwrap(SessionFactoryImplementor.class);
SQLFunction fnc = d.getSqlFunctionRegistry()
.findSQLFunction("fncName“);
String render = fnc.render(null, expressions,
this.entityManagerFactory.unwrap(SessionFactoryImplementor.class));
the first part I guess should be
SqlFunction fnc = (SqlFunction) d.getQueryEngine().getSqmFunctionRegistry().findFunctionDescriptor("fncName“);
but I am stuck with the the 2nd part
SessionFactoryImplementor
is documented as an SPI, and so we don't really recommend using it in this way.
/**
* Defines the internal contract between the {@link SessionFactory} and the internal
* implementation of Hibernate.
At least, if you do this sort of thing, you do it at your own risk.
As you've noticed, SqmFunctionDescriptor
, which is the replacement for SQLFunction
, is a much more technical API, which was a very necessary change, because Hibernate's handling of functions is now much more sophisticated.
I can't really imagine why you would want to be hand-rendering a function invocation, but I'm sure you must have your reasons. Whatever they are, I think it's not likely to work, at least not without an unreasonable amount of messiness.
Sorry.