Hi,
I’m using Quarkus and Hibernate. There is a custom class which extends QuarkusH2Dialect. But after migration to Hibernate 6 it doesn’t work anymore. What is the solution?
import io.quarkus.hibernate.orm.runtime.dialect.QuarkusH2Dialect
import org.hibernate.dialect.function.SQLFunction
import org.hibernate.engine.spi.Mapping
import org.hibernate.engine.spi.SessionFactoryImplementor
import org.hibernate.type.StringType
import org.hibernate.type.Type
class MyDialect : QuarkusH2Dialect() {
init {
registerFunction(
"calculate_hash",
object : SQLFunction {
override fun hasArguments() = true
override fun hasParenthesesIfNoArguments() = false
override fun getReturnType(firstArgumentType: Type?, mapping: Mapping?) = StringType.INSTANCE
override fun render(firstArgumentType: Type?, arguments: List<Any?>?, factory: SessionFactoryImplementor?) =
"hash('calculate_hash', ${arguments?.first()})"
}
)
}
}