New HQL ANTLR base parser bug.Please JIRA with test case. The best workaround is : <property name ="query.factory_class"> NHibernate.Hql.Classic.ClassicQueryTranslatorFactory, NHibernate </property>
2009/7/30 michal <[email protected]> > > Hello > > After migration from NH 2.0.1 to 2.1.0 , I have huge problem with HQL > joins. They worked well in 2.0.1. > > For example : > There are three classes : Mas, Det, El . Det has many-to-one relation > to Mas. Mas has many-to-may relation to El. > > HQL: select d from Det d where (SELECT count(e) FROM d.Mas.Els e WHERE > e.Descr='e1')>0 > > SQL (proper) : > select det0_.Id as Id2_, det0_.Descr as Descr2_, det0_.IdMas as > IdMas2_ from det det0_ where (select count(el3_.Id) from mas mas1_, > MasEls els2_, Els el3_ where det0_.IdMas=mas1_.Id and > mas1_.Id=els2_.IdMas and els2_.IdEls=el3_.Id and el3_.Descr='e1')>0 > > But adding a simple join , makes the resulting subquery a real mess, > wrong table is used : > > HQL: select d from Det d left join d.Mas where (SELECT count(e) FROM > d.Mas.Els e WHERE e.Descr='e1')>0 > > SQL (bad) : > select det0_.Id as Id2_, det0_.Descr as Descr2_, det0_.IdMas as > IdMas2_ from det det0_ left outer join mas mas1_ on > det0_.IdMas=mas1_.Id where (select count(mas1_.Id) from mas mas1_ > where mas1_.Descr='e1')>0 > > I need this joins because in my real app queries are more complicated > and dynamically build, without them I do not get some results. I know > the workaround, it is : > select d from Det d left join d.Mas m where (SELECT count(e) FROM > m.Els e WHERE e.Descr='e1')>0 > > but it means reviewing tons of code for me. Why it is working > different than in 2.0.1 ? Can be an old behaviour restored by some way > or is this a bug ? I didn't find anything about joins in breaking > changes list. > > Please help. > > > Example class mappings below > <class name="Mas" table="mas" > > <id name="Id" type="Int32" > > <generator class="assigned" /> > </id> > > <property name="Descr" type="String" /> > <set name="Els" table="MasEls" > > <key column="IdMas" /> > <many-to-many column="IdEls" class="El"/> > </set> > </class> > > <class name="Det" table="det" > > <id name="Id" type="Int32" > > <generator class="assigned" /> > </id> > > <property name="Descr" type="String" /> > <many-to-one class="Mas" name="Mas" column="IdMas" /> > </class> > > <class name="El" table="Els" > > <id name="Id" type="Int32" > > <generator class="assigned" /> > </id> > <property name="Descr" type="String" /> > </class> > > > > > > -- Fabio Maulo --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
