java - Querydsl - Split results into two or more objects -
i have query that's returning list of objects (say employee), , i'd append total, unpaged count(*) of results along side it. like:
+---+-------------------+-------------+------------+ | | id | age | total | +---+-------------------+-------------+------------+ | 1 | 1234 | 24 |12 | | 2 | 154367 | 61 |12 | | 3 | 9485048386 | 36 |12 | +---+-------------------+-------------+------------+ which emulating query like:
select * , count(*) over() total employee limit 3 offset 0 how can query type of data , retrieve list<employee> , singular long total? currently, have going, i'm uncertain how expand new total column/value:
projection = projections.constructor(employee.class, qemployee.id, qemployee.age); select(projection).from(qemployee).where(foobar).offset(0).limit(3);
i able achieve adding sqlexpression needed window function select(...). query returns list<tuple> first element of tuple employee object, , second total:
projection = projections.constructor(employee.class, qemployee.id, qemployee.age); list<tuple> results = select(projection, sqlexpressions.count().over()).from(qemployee).where(foobar).offset(0).limit(3);
Comments
Post a Comment