Hello,
I am using Beta2 of NHibernate and another issue occured to me (maybe I had this error before as well...)
I have two classes: class Task and class TaskCategory. Now I want to do a (hql)query like that:
Code:
SELECT t.Id FROM Task t order by t.Category.Name
NHibernate translates this query into this sql query:
Code:
select task0_.Id as x0_0_ from Tasks task0_, TaskCategories taskcatego1_ where task0_.CategoryId=taskcatego1_.Id order by taskcatego1_.Name
As you can see NHibernate does not use outer joins - therefore all the tasks that have no associated category don't get fetched.
I would have expected this query:
Code:
select task0_.Id as x0_0_ from Tasks task0_ LEFT OUTER JOIN TaskCategories taskcatego1_ ON task0_.CategoryId=taskcatego1_.Id order by taskcatego1_.Name
Is it possible to make NHibernate query like I want? :)
Btw: my mapping of class Task looks something like this:
Code:
<class name="Task" table="Tasks" >
<id name="Id" column="Id" unsaved-value="0">
<generator class="native" />
</id>
<many-to-one name="Category" column="CategoryId" outer-join="true"
foreign-key="FK_Tasks_Category" class="TaskCategory" />
</class>
I hope you'll help me. Thank you in advance,
Dominik