Description
Doan Van Tuan created an issue — 18th March 2013, 3:03:37:
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.
Doan Van Tuan added a comment — 18th March 2013, 4:56:07:
This time, the exception is SqlException due to an invalid SQL
Oskar Berggren added a comment — 18th March 2013, 6:41:22:
Doesn't this sound similar to NH-3178?
Doan Van Tuan added a comment — 18th March 2013, 6:50:39:
@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 added a comment — 19th March 2013, 8:47:32:
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 added a comment — 19th March 2013, 9:33:10:
After remove property-ref="User" from mapping, all works well.
I misunderstood the use of property-ref.
Alexander Zaytsev added a comment — 19th March 2013, 22:09:27:
Shall we close the issue?
Doan Van Tuan added a comment — 20th March 2013, 2:50:09:
I think the faulty SQL generation in this case is interesting, but it's not important now. Please close the issue.