CriteriaQuery<Object[]> cq = cb.createQuery(Object[].class);
Root<Entity> from = cq.from(Entity.class);
cq.multiselect(from.get(Entity_.field1),from.get(Entity_.field2))
.where(
... predicates
)
.orderBy(cb.asc(from.get(Entity_.field1)));
When using Object[].class to create a CriteriaQuery with multiselect (without specifying aliases), the generated SQL ORDER BY clause appears as ORDER BY 1 (positional index) instead of the column name (e.g., id ).
Is there any configuration or alternative approach to force Hibernate to always generate ORDER BY clauses using column names (e.g., ORDER BY id ) rather than positional indexes?
THANKS