jOOQ - 方法调用

Wic*_*cia 3 java sql methods invoke jooq

我有关于在以下示例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)
Run Code Online (Sandbox Code Playgroud)

我试图创建这样的机制来调用方法而不使用对象/类引用,但我放弃了.它真的有可能实现吗?

感谢帮助.

Wicia

Luk*_*der 5

挂在那儿!:-)

你引用了网站上的第一个例子.我建议按照手册中关于如何阅读手册的部分(我知道,这听起来像我是RTFM的你.对不起),你会发现一些解释,例如

// 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...
Run Code Online (Sandbox Code Playgroud)

教程还介绍了如何执行此操作,即使用静态导入:

// 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.*;
Run Code Online (Sandbox Code Playgroud)

请注意,有一个待处理的功能请求#3503用于改进手册和带有工具提示的网站,以便向新用户解释这些内容,一旦您掌握了jOOQ,这将很快成为常见做法.