2017-05-25 7 views
0

Ich habe diese Anfrage:Sql mit Fensterfunktion auf jOOQ

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

ich es in jOOQ übersetzen möchte, wie könnte ich das erreichen?

Antwort

1

Unter der Annahme, diese statische Import

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

Und dann

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();