2014-08-28 24 views
3

我有問題有關在下面的示例jOOQ聲明調用方法計數()jOOQ - 方法調用

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) 

我試圖創建這樣的機制來調用方法不使用對象/類引用,但我放棄了。真的有可能實現它嗎?

感謝您的幫助。

Wicia

回答

5

掛在那裏! :-)

你引用了網站的第一個例子。我建議遵循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的掛件,這將很快成爲慣例。