JPQL makes this kind of change very easy:
Select o from Orders as o where....
Select o.id from Orders as o where....
But in Criteria Query:
CriteriaBuilder builder = kem.getCriteriaBuilder();
CriteriaQuery<Orders> query = builder.createQuery(Orders.class);
Root<Order> orders= query.from(Orders.class);
query.select(orders);
....
It looks that the select item is defined by builder.createQuery(Order.class) already without any flexibility.
I know we can use Tuple.class, but other than like is there any better way to just extra id(just one field) from a complicated query? Without such feature criteria query becomase very lack of flexibility.