Exception when using one-to-one properties in a criteria projections

Description

I get the following exception when using a one-to-one property in a criteria projection:

NHibernate.Exceptions.GenericADOException: could not execute query
[ SELECT this_.USERID as y0_ FROM USER this_ ]
[SQL: SELECT this_.USERID as y0_ FROM USER this_] ---> System.IndexOutOfRangeException: Index was outside the bounds of the array.
at NHibernate.Loader.Criteria.CriteriaLoader.GetResultColumnOrRow(Object[] row, IResultTransformer customResultTransformer, IDataReader rs, ISessionImplementor session) in d:\GitHub\nhibernate\nhibernate-core\src\NHibernate\Loader\Criteria\CriteriaLoader.cs:line 101
at NHibernate.Loader.Loader.GetRowFromResultSet(IDataReader resultSet, ISessionImplementor session, QueryParameters queryParameters, LockMode[] lockModeArray, EntityKey optionalObjectKey, IList hydratedObjects, EntityKey[] keys, Boolean returnProxies) in d:\GitHub\nhibernate\nhibernate-core\src\NHibernate\Loader\Loader.cs:line 360
at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) in d:\GitHub\nhibernate\nhibernate-core\src\NHibernate\Loader\Loader.cs:line 468
at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) in d:\GitHub\nhibernate\nhibernate-core\src\NHibernate\Loader\Loader.cs:line 246
at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) in d:\GitHub\nhibernate\nhibernate-core\src\NHibernate\Loader\Loader.cs:line 1590
— End of inner exception stack trace —
at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) in d:\GitHub\nhibernate\nhibernate-core\src\NHibernate\Loader\Loader.cs:line 1599

Using many-to-one projections on the other hand does work. The difference seems to be the AbstractType.GetColumnSpan method which returns a hard coded zero in the OneToManyType override and a non-zero value in the ManyToOneType override.

Environment

None

Assignee

Alex Zaytsev

Reporter

Nathan Baulch

Components

Fix versions

Affects versions

Priority

Minor
Configure