我正在使用Quarkus和Hibernate。有一个扩展QuarkusH2Dialect的自定义类。但迁移到Hibernate 6后,它就不再工作了。它被移除了。你能提供一些建议,如何修复它?
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()})"
}
)
}
}
字符串
1条答案
按热度按时间hs1ihplo1#
扩展
org.hibernate.dialect.H2Dialect
。或者,更好的方法是通过自定义的
MetadataBuilderContributor
注册函数:个字符
标签:https://github.com/quarkusio/quarkus/issues/32936