Let say I have a generic method using JPA to list out entities
    public <T> List<T> list(Class<T> entity) throws Exception {
        List<T> result = new ArrayList<T>();
        CriteriaBuilder builder = em.getCriteriaBuilder();
        CriteriaQuery<T> query = builder.createQuery( entity );
        Root<T> root = query.from( entity );
        query.select( root );
        //possible?
        query.orderBy(builder.asc(...));
        result = em.createQuery( query ).getResultList();
        return result;
   }
Is there anyway for us to add orderby to the query and make it order by the primary key without specify the primary column as the expression? I mean, is there a Key/Constant or something in JPA meaning a primary key column of any entity, or a util method to retrieve it?