CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<TableA> TableA = cq.from(TableA.class);
Join<TableA, TableB> join1 = TableA.join(TableB);
//cq.orderBy(cb.desc(TableA.join(RUN_CORE_PIECES))).distinct(true);
Join<TableB, TableC> join2 = TableB.join(TableC);
//cq.select(tableA.join("TableB").get("TableC")).distinct(true);
I’m new to Criteria Builder and I’ve been stuck for hours. I’m trying to join three tables. For the join between A and B, is it possible to sort Table B first before joining it? I wanted to return the last value of the table B join distinct. The commented out code were things I was trying that didn’t work.
I tried sorting it but what I get in return is the all three tables joined then sorted by descending, instead of sorting on table B then joining the tables.