Help definining query in criteria builder #1930
Unanswered
rybandrei2014
asked this question in
Q&A
Replies: 1 comment
-
You will have to use a @CTE
@Entity
class Table2Cte {
@Id
private Long id;
private Long order;
} then you can write something like this: CriteriaBuilder<Tuple> cb = cbf.create(em, Tuple.class)
.from(Table1Entity.class, "t1")
.where("t1.id").in()
.fromSubquery(Table2Cte.class, "c")
.from(Table2Entity.class, "t2")
.bind("id").select("t2.id")
.bind("order").select("t2.order")
.orderByAsc("coalesce(t2.order, t2.id)")
.setFirstResult(10)
.setMaxResults(10)
.end()
.select("c.id")
.end()
.select("t1.id")
.select("t1.a")
.select("t1.b")
.select("t1.c"); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
how do I define the following query in Blaze persistence Criteria builder. Unfortunately, haven't found the exact use-case in documentation... Particularly I'm interested how to define FROM clause from subquery.
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions