Following code in Criteria Api:
Criteria criteria = getCriteria( RootClass.class );
criteria.createAlias( "b", "b" );
criteria.createAlias( "b.c", "c" );
criteria.createAlias( "a", "a", JoinType.INNER_JOIN, Restrictions.eqProperty( "a.keyId", "c.id" ) );
ignores order of adding aliases to criteria and produces following SQL query:
select [...]
from Root_Object this_
inner join A a3 on a3.KEY_ID = c2.ID
inner join B b1 on this_.ID = b1.COLUMN_ID
inner join C c2 on b1.ID = c2.COLUMN_ID
then MSSQL 2008 throws error:
SQLException: The multi-part identifier "c2.ID" could not be bound.
If I change the name of collection 'a' to 'z' in root entity then query:
select [...]
from Root_Object this_
inner join B b1 on this_.ID = b1.COLUMN_ID
inner join C c2 on b1.ID = c2.COLUMN_ID
inner join A z3 on z3.KEY_ID = c2.ID
returns correct results without error
|