criteria loader runs into ArrayIndexOutOfBoundsException caused by wrong condition handling for column span zero

Description

Retriving results from a query with a last column with zero column span we run into ArrayOutOfBoundsException.

An easy fix:
org.hibernate.loader.criteria.CriteriaLoader (revision 20078) method getResultColumnOrRow(Object[], ResultTransformer, ResultSet, SessionImplementor)
In line 143 condition ">" should change to "!=". The variable pos is not a valid index for columnAlias when numColumns (=column span) is 0. ArrayHelper.slice handles condition numColumns zero correctly.

Alternative workaround:
Change how the query is built. The last column should be at another position in the query.

Environment

None

Assignee

Unassigned

Reporter

Christoph W.

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

Priority

Major
Configure