Closed
Description
After upgrading from NHibernate 5.1 to 5.2 a unit tests failed due to incorrectly generated alias for subcriteria on a component collection:
SQLite Error 1: 'no such column: code2_.code_source_id'.
The generated SQL looks as follows:
SELECT this_.concept_id as concept1_3_2_
, conceptcod5_.code_id as code1_1_0_
, conceptcod5_.code_source_id as code4_1_0_
, conceptcod5_.value as value5_1_0_
, conceptcod5_.name as name6_1_0_
FROM concept this_
inner join concept_mapping cm1_ on this_.concept_id=cm1_.concept_id
left outer join concept_code conceptcod5_ on cm1_.code_id=conceptcod5_.code_id
WHERE code2_.code_source_id in (@p0)
and code2_.value in (@p1, @p2, @p3)
The problem is that in the WHERE clause the SQL alias code2_
is used for table concept_code
but in the FROM clause the SQL alias conceptcod5_
is defined for the same table.