CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Object> criteriaQuery = cb.createQuery();
Root<User> root = criteriaQuery.from(User.class);
criteriaQuery.where(cb.equal(root.get("id"), cb.parameter(Integer.class, "id")));
criteriaQuery.select(root.get("id").alias("x"));
em.createQuery(criteriaQuery);