I was wondering if it\'s possible to create such query like :
em.createQuery(
\"SELECT NEW EmpMenu(p.name, p.department.name) \"
+ \"FROM Pro
Yes, Criteria API does have have construct similar to JPQL constructor expressions. Result class is set via construct method in CriteriaBuilder.
Your JPQL query expressed as an criteria query is:
CriteriaBuilder cb...
CriteriaQuery<EmpMenu> q = cb.createQuery(EmpMenu.class);
Root<Project> c = q.from(Project.class);
q.select(cb.construct(EmpMenu.class,
c.get("name"), c.get("department").get("name")));