2017-05-25 56 views
0

我有這個疑問:SQL和窗口功能JOOQ

SELECT id, url, name, email, count(*) OVER() AS overallCount 
FROM images 
WHERE email = ? 
OFFSET ? 
LIMIT ? 

我想將它翻譯成JOOQ,我怎麼能做到這一點?

回答

1

假設這個靜態導入

import static org.jooq.impl.DSL.*; 

然後

String email = ... 
int offset = ... 
int limit = ... 

using(configuration) 
    .select(
    IMAGES.ID, 
    IMAGES.URL, 
    IMAGES.EMAIL, 
    count().over().as("overallCount")) 
    .from(IMAGES) 
    .where(IMAGES.EMAIL.eq(email)) 
    .offset(offset) 
    .limit(limit) 
    .fetch();