IndexOutOfRangeException when querying subclass mapped object that have one-to-one mapping with other object

Description

Happen with a class mapped with subclass mapping, and a subclass has a one-to-one property mapped to another class using shared primary key. Query the subclass with join alias to the one-to-one class, IndexOutOfRangeException will be thrown.
(MsSql 2008, .Net 4.0)
A test case will be attached shortly.

Environment

None

Activity

Show:
Doan Van Tuan
March 18, 2013, 6:50 AM

@Oskar: Not exactly the same.
The problem with this one is the SQL generated is not complete: the condition in Where clause is missing, so the SQL where is like this: "... WHERE and Type='3'". So if NHibernate try to bind SqlParameter, IndexOutOfRangeException will be thrown, and if the SQL is sent to database, a SqlException.
The exception in #NH-3178 happen in a different place.

Doan Van Tuan
March 19, 2013, 8:47 AM

I have just attached a revised test fixture, which shows that the problem is not limited to QueryOver. HQL and CriteriaAPI is also affected.
Am I mapped the classes wrongly?

Doan Van Tuan
March 19, 2013, 9:33 AM

After remove property-ref="User" from mapping, all works well.
I misunderstood the use of property-ref.

Alex Zaytsev
March 19, 2013, 10:09 PM

Shall we close the issue?

Doan Van Tuan
March 20, 2013, 2:50 AM

I think the faulty SQL generation in this case is interesting, but it's not important now. Please close the issue.

Assignee

Unassigned

Reporter

Doan Van Tuan

Components

Affects versions

Priority

Trivial
Configure