I\'m trying to create a criteria to retrieve some objects from 3 tables (Associate, Update and Detail). A Detail has reference to Associate and Update, and an Update has ref
Each join takes you from the leftish type parameter to the rightish one. So, the details
join of my code (second line) starts from fromUpdates
, that is a Path
, and creates something which is behind the scenes also a Path
. From that, you can build other joins. Try this (code not tested):
Root fromUpdates = query.from(Update.class);
Join details = fromUpdates.join("details");
Join associate = details.join("associate");
List conditions = new ArrayList();
conditions.add(builder.equal(associate.get("associateId"), associateId));
conditions.add(builder.isNull(details.get("ack_date")));
TypedQuery typedQuery = em.createQuery(query
.select(fromUpdates)
.where(conditions.toArray(new Predicate[] {}))
.orderBy(builder.asc(fromUpdates.get("updateId")))
.distinct(true)
);