CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<Object[]> criteria = builder.createQuery(Object[].class);
Root<PostComment> root = criteria.from(PostComment.class);
Join<PostComment, Post> postJoin = root.join("post");
criteria.multiselect(
root.get(PostComment_.id).alias("id"),
root.get(PostComment_.review).alias("review"),
postJoin.get(Post_.title).alias("title")
);
criteria.where(builder.like(postJoin.get(Post_.title), "high-performance%"));
List<PostCommentSummary> comments = entityManager
.createQuery(criteria)
.unwrap(Query.class)
.setResultTransformer(Transformers.aliasToBean(PostCommentSummary.class))
.getResultList();