Jooq &引用;“未找到合适的方法”;在尝试实现自定义绑定时
我在尝试为Postgres ltrees创建自定义绑定时收到以下消息:Jooq &引用;“未找到合适的方法”;在尝试实现自定义绑定时,jooq,Jooq,我在尝试为Postgres ltrees创建自定义绑定时收到以下消息: [...]/jooq/routines/JSubpath1.java:37: error: no suitable method found for createParameter(String,DataType<Integer>,boolean,boolean,LtreeBinding) public static final Parameter<String> _2 = Internal.
[...]/jooq/routines/JSubpath1.java:37: error: no suitable method found for createParameter(String,DataType<Integer>,boolean,boolean,LtreeBinding)
public static final Parameter<String> _2 = Internal.createParameter("_2", org.jooq.impl.SQLDataType.INTEGER, false, true, new LtreeBinding());
^
method Internal.<T#1>createParameter(String,DataType<T#1>,boolean,boolean) is not applicable
(cannot infer type-variable(s) T#1
(actual and formal argument lists differ in length))
method Internal.<T#2,U#1>createParameter(String,DataType<T#2>,boolean,boolean,Converter<T#2,U#1>) is not applicable
(cannot infer type-variable(s) T#2,U#1
(argument mismatch; LtreeBinding cannot be converted to Converter<T#2,U#1>))
method Internal.<T#3,U#2>createParameter(String,DataType<T#3>,boolean,boolean,Binding<T#3,U#2>) is not applicable
(inference variable T#3 has incompatible equality constraints Object,Integer)
method Internal.<T#4,X,U#3>createParameter(String,DataType<T#4>,boolean,boolean,Converter<X,U#3>,Binding<T#4,X>) is not applicable
(cannot infer type-variable(s) T#4,X,U#3
(actual and formal argument lists differ in length))
[…]/jooq/routines/JSubpath1.java:37:错误:找不到createParameter(字符串、数据类型、布尔值、布尔值、LtreeBinding)的合适方法
公共静态最终参数_2=Internal.createParameter(“_2”,org.jooq.impl.SQLDataType.INTEGER,false,true,new LtreeBinding());
^
方法内部。createParameter(字符串、数据类型、布尔值、布尔值)不适用
(无法推断类型变量T#1
(实际参数列表和正式参数列表长度不同))
方法内部。createParameter(字符串、数据类型、布尔值、布尔值、转换器)不适用
(无法推断类型变量T#2,U#1
(参数不匹配;LtreeBinding无法转换为转换器))
方法内部。createParameter(字符串、数据类型、布尔值、布尔值、绑定)不适用
(推理变量T#3具有不兼容的等式约束对象,整数)
方法内部。createParameter(字符串、数据类型、布尔值、布尔值、转换器、绑定)不适用
(无法推断类型变量T#4,X,U#3
(实际参数列表和正式参数列表长度不同))
以下是装订:
class LtreeBinding : Binding<Any, String> {
override fun converter(): Converter<Any, String> {
return object : Converter<Any, String> {
override fun from(dbAny: Any?): String? {
return dbAny?.toString()
}
override fun to(userAny: String?): Any? {
return userAny as Any
}
override fun fromType(): Class<Any> {
return Any::class.java
}
override fun toType(): Class<String> {
return String::class.java
}
}
}
override fun sql(ctx: BindingSQLContext<String>) {
ctx.render()?.let {
if (it.paramType() == ParamType.INLINED) {
it.visit(
DSL.inline(ctx.convert(converter()).value())
)
} else {
it.sql("?")
}
}
}
override fun register(ctx: BindingRegisterContext<String>) {
ctx.statement().registerOutParameter(ctx.index(), Types.VARCHAR)
}
override fun set(ctx: BindingSetStatementContext<String>) {
ctx.statement().setString(
ctx.index(),
ctx.convert(converter()).value()?.toString()
)
}
override fun set(ctx: BindingSetSQLOutputContext<String>) {
throw SQLFeatureNotSupportedException()
}
override fun get(ctx: BindingGetResultSetContext<String>) {
ctx.convert(converter()).value(ctx.resultSet().getString(ctx.index()))
}
override fun get(ctx: BindingGetStatementContext<String>) {
ctx.convert(converter()).value(ctx.statement().getString(ctx.index()))
}
override fun get(ctx: BindingGetSQLInputContext<String>) {
throw SQLFeatureNotSupportedException()
}
}
类LtreeBinding:绑定{
覆盖乐趣转换器():转换器{
返回对象:转换器{
覆盖来自(dbAny:Any?):字符串的乐趣{
返回dbAny?.toString()
}
将乐趣覆盖到(userAny:String?):Any{
将userAny作为Any返回
}
重写fromType():类{
返回Any::class.java
}
重写fun toType():类{
返回字符串::class.java
}
}
}
重写sql(ctx:BindingSQLContext){
ctx.render()?.let{
if(it.paramType()==paramType.INLINED){
它。访问(
DSL.inline(ctx.convert(converter()).value())
)
}否则{
it.sql(“?”)
}
}
}
覆盖趣味寄存器(ctx:BindingRegisterContext){
ctx.statement().registerOutParameter(ctx.index(),Types.VARCHAR)
}
覆盖乐趣集(ctx:BindingSetStatementContext){
ctx.statement().setString(
ctx.index(),
ctx.convert(converter()).value()?.toString()
)
}
覆盖乐趣集(ctx:BindingSetSQLOutputContext){
抛出SQLFeatureNotSupportedException()
}
覆盖趣味获取(ctx:BindingGetResultContext){
convert(converter()).value(ctx.resultSet().getString(ctx.index()))
}
重写fun-get(ctx:BindingGetStatementContext){
convert(converter()).value(ctx.statement().getString(ctx.index()))
}
重写fun-get(ctx:BindingGetSQLInputContext){
抛出SQLFeatureNotSupportedException()
}
}
生成器配置是在Gradle“build”文件中的XML中完成的。生成的代码位于src/main/java/generated
中,而其余代码(包括绑定)位于src/main/kotlin
中
有什么不对劲吗?错误日志实际上没有给我任何线索。生成的代码如下:
Internal.createParameter(“_2”,SQLDataType.INTEGER,false,true,new LtreeBinding());
这意味着参数的数据类型是
INTEGER
,而不是OTHER
。因此,您的绑定不能是绑定类型。您的类路径上是否有匹配的代码生成器和运行库版本?是的。所有参数均设置为3.13.5@LukaSederIncludedTypes中用ltree
替换*
有帮助。谢谢