Relative Content

Tag Archive for javacriteriabuilder

How to Join Two Tables with Criteria Builder and Grab the First Distinct Value in Descending Order?

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 […]