jOOQ如何执行Postgresql函数和操作符
jOOQ how to execute Postgresql functions and operators
我正在使用 jooq 3.9.1。我想通过添加基于 PostgreSQL 运算符和函数的条件来编写查询。
例如,对于数组,有很多我想使用的运算符,例如 &&
或 array_prepend
等函数。
实现此目标的最佳方法是什么?
我觉得应该是这样的
int[] array_of_values = {1,2,3};
selectOne()
.from(TABLE)
.where(TABLE.COL_A.eq("Hello"))
.and(TABLE.COL_B.operator("&&").of(array_of_values))
.fetch();
在 jOOQ 3.9 中,标准的前进方式是 use the plain SQL API
selectOne()
.from(TABLE)
.where(TABLE.COL_A.eq("Hello"))
.and("{0} && {1}", TABLE.COL_B, val(array_of_values))
.fetch();
这是使用 SelectConditionStep.and(String, QueryPart...)
method for convenience, but there are other ways, including using DSL.condition()
你的想法很好。我注册了 feature request for jOOQ 3.10.
我正在使用 jooq 3.9.1。我想通过添加基于 PostgreSQL 运算符和函数的条件来编写查询。
例如,对于数组,有很多我想使用的运算符,例如 &&
或 array_prepend
等函数。
实现此目标的最佳方法是什么?
我觉得应该是这样的
int[] array_of_values = {1,2,3};
selectOne()
.from(TABLE)
.where(TABLE.COL_A.eq("Hello"))
.and(TABLE.COL_B.operator("&&").of(array_of_values))
.fetch();
在 jOOQ 3.9 中,标准的前进方式是 use the plain SQL API
selectOne()
.from(TABLE)
.where(TABLE.COL_A.eq("Hello"))
.and("{0} && {1}", TABLE.COL_B, val(array_of_values))
.fetch();
这是使用 SelectConditionStep.and(String, QueryPart...)
method for convenience, but there are other ways, including using DSL.condition()
你的想法很好。我注册了 feature request for jOOQ 3.10.