hi there,
i encountered a very strange problem with nhibernate and sql server 2005 express.
i have 3 classes all related to each other in SQL Server.
when i do the query stated below ("from vehicle v where v.device.imei = '123456'") , it retrieves a row from the database. but the wrong row.
if i do a manual select in sql (select * from vehicles,devices where vehicles.devicid = devices.deviceid and devices.deviceIMEI = '123456') it returns the correct vehicle, but it doesnt with the HQL statement.
any ideas what to do?
it works on 2 machines, but not on another one...
i´m kinda desperate ^^
NHibernate version:
Build 1.2.0.GA
Mapping documents:
<class name="MyNamespaces.Vehicle, MyFile" table="Vehicles" lazy="true">
<id name="VehicleID" column="VehicleID" type="int">
<generator class="identity"/>
</id>
<one-to-one name="Device" class="MyNamespace.Device, MyFile"
fetch="join"/>
</class>
<class name="MyNamespace.Waypoint, MyFile" table="WayPoints" lazy="false">
<id name="ID" column="WaypointID" type="Int64">
<generator class="identity"/>
</id>
<many-to-one name="Vehicle" class="MyNamespace.Vehicle, MyFile" column="VehicleID"/>
</class>
<class name="MyNameSpace.Device, MyFile" table="Devices" lazy="false">
<id name="DeviceID" column="DeviceID" type="integer">
<generator class="identity"/>
</id>
<property name="Type" column="DeviceType" type="integer"/>
<property name="IMEI" column="DeviceIMEI" type="string" length="15"/>
</class>
Code between sessionFactory.openSession() and session.close():
Code:
IQuery q = session.CreateQuery(string.Format("from Vehicle as v where v.Device.IMEI = '{0}'",data.IMEI));
Full stack trace of any exception that occurs:
none
Name and version of the database you are using:
SQL Server 2005 Express
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: