Params from main orderBy query are trying to be inserted to subselect query ->parameter index out of range

Description

There are two entities: Post and Comment.
Post has collection of comments that are selected in subselect query:
@OneToMany(mappedBy = "post", fetch = FetchType.EAGER, cascade = CascadeType.MERGE)
@Fetch(value = FetchMode.SUBSELECT)
private List<Comment> comments;
When Post entities are selected by CriteriaQuery with specific 'orderBy' expression that contains params (see fragment below), exception 'SQLException: Parameter index out of range (1 > number of parameters, which is 0).' is thrown.
Order order = builder.desc(builder.coalesce(root.get("name"), "default_name"));
query.orderBy(order);
ORMUnitTestCase:

Environment

java 1.8+, hibernate-core 5.4.18.Final, any DB

Assignee

Unassigned

Reporter

Raman Kreidzich

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure