order by is being ignored when using CriteriaBuilder

Description

consider the following piece of code:

it generates the following SQL, which is wrong:

moreover, if I change the code as follows:

I get cast exception

Note that running the above code with a local build from wip/6.0 branch produces a different error:

and below is a new test case for org.hibernate.orm.test.query.criteria.BasicCriteriaExecutionTests which fails now

Environment

None

Assignee

Unassigned

Reporter

Adrian Pulbere

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

Yes, likely

Requires Release Note

None

Pull Request

None

backportDecision

None

Worked in

5.4.3

Components

Affects versions

Priority

Major
Configure