【问题标题】:jOOQ - method invokingjOOQ - 方法调用
【发布时间】:2014-08-28 06:53:47
【问题描述】:

我对在以下示例 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)

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

感谢您的帮助。

维西亚

【问题讨论】:

    标签: java sql methods invoke jooq


    【解决方案1】:

    坚持住! :-)

    您引用了网站上的第一个示例。我建议关注manual's section about how to read the manual(我知道,这听起来像是我在向你发送 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...
    

    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,这将很快成为惯例。

    【讨论】:

      猜你喜欢
      • 2013-12-05
      • 2018-08-10
      • 2020-06-08
      • 2017-01-08
      • 2013-10-02
      • 1970-01-01
      • 2021-04-03
      • 2017-10-30
      • 2018-04-16
      相关资源
      最近更新 更多