Hibernate version: 3.0
Name and version of the database you are using: MSSQL 7
For some reason when I use a Query, setting parameter to null, like so:
Query:
("... and menuitem.parentMenu = :parent ..")
.....
.setParameter("parent", null, Hibernate.entity(Menuitem.class));
Generated sql shows:
and menuitem0_.relationid=?
That of course doesnt return proper results. However if I use my Query like:
("... and menuitem.parentMenu is null ..") or even
("... and menuitem.parentMenu = null ..")
Generated sql shows:
and (menuitem0_.relationid is null)
which return correct results.
The mapping file looks like this:
<class name="Menuitem" table="menuitem">
<id name="itemid" column="itemid" type="java.lang.Long">
<generator class="native" />
</id>
<property name="itemname" column="itemname"
type="java.lang.String" not-null="true" />
<property name="orderid" column="orderid"
type="java.lang.Integer" not-null="true" />
<bag name="childMenues" cascade="all-delete-orphan" outer-join="false"
inverse="true" lazy="true" batch-size="10" order-by="orderid">
<key column="relationid" />
<one-to-many class="Menuitem" />
</bag>
<many-to-one name="parentMenu" cascade="none"
outer-join="false">
<column name="relationid" not-null="false" />
</many-to-one>
</class>
Is it supposed to behave like that or I am missing something? Thank you for the help, Oleg.
|