我对在以下示例 jOOQ 语句中调用方法 count() 有疑问:
create.select(AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME, count())
.from(AUTHOR)
.join(BOOK).on(AUTHOR.ID.equal(BOOK.AUTHOR_ID))
.where(BOOK.LANGUAGE.eq("DE"))
.and(BOOK.PUBLISHED.gt(date("2008-01-01")))
.groupBy(AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME)
.having(count().gt(5))
.orderBy(AUTHOR.LAST_NAME.asc().nullsFirst())
.limit(2)
.offset(1)
.forUpdate()
.of(AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME)
我曾尝试创建这样的机制来调用方法而不使用对象/类引用,但我已经放弃了。真的可以实现吗?
感谢您的帮助。
维西亚
最佳答案
坚持住! :-)
您引用了网站上的第一个示例。我建议遵循 manual's section about how to read the manual (我知道,这听起来像是我在 RTFM'ing 你。很抱歉),你会在那里找到一些解释,例如
// Whenever you see "standalone functions", assume they were static imported
// from org.jooq.impl.DSL. "DSL" is the entry point of the static query DSL
exists(); max(); min(); val(); inline();
// correspond to DSL.exists(); DSL.max(); DSL.min(); etc...
tutorial还展示了如何做到这一点,即使用静态导入:
// For convenience, always static import your generated tables and
// jOOQ functions to decrease verbosity:
import static test.generated.Tables.*;
import static org.jooq.impl.DSL.*;
请注意,有一个待处理的功能请求 #3503改进手册和带有工具提示的网站,以便向新用户解释这些事情,一旦您掌握了 jOOQ,这将很快成为普遍做法。
关于java - jOOQ - 方法调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25542514/