Hello,
i have a problem: I enlarget a table of my database. I also enlarget des hbm.xml file and the fitting c# class. Then i fit my hql query, afterwards i get an DataAcessException. The problem is, when i use the SQL query (from log4net) generated by nhibernate directly on the database i get an result, but my hql query (hqlString = "select s from StorageEntity s where s.Storageno='A' and s.Tower =1 and s.Side='A' and s.Area=8 and s.Tray='B' and s.Size= 4'") didn't get a result.
Hibernate version:
nHibernate 2.0 Alpha1
Mapping documents:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="false">
<class name="Storage.Server.Data.Storage.Entity.StorageEntity, Storage.Server" table="STORAGE" >
<id name="Id" column="STORAGE_ID" type="System.Decimal" unsaved-value="null">
<generator class="sequence">
<param name="sequence">STORAGE_SEQ</param>
</generator>
</id>
<property name="Storageno" column="STORAGE_NO" access="field.pascalcase-underscore" not-null="false" type="System.String" insert="true" update="true"/>
<property name="Area" column="AREA" access="field.pascalcase-underscore" not-null="false" type="System.Decimal" insert="true" update="true"/>
<property name="Side" column="SIDE" access="field.pascalcase-underscore" not-null="false" type="System.String" insert="true" update="true"/>
<property name="Size" column="SIZ" access="field.pascalcase-underscore" not-null="false" type="System.Decimal" insert="true" update="true"/>
<property name="Tower" column="TOWER" access="field.pascalcase-underscore" not-null="false" type="System.Decimal" insert="true" update="true"/>
<property name="Tray" column="TRAY" access="field.pascalcase-underscore" not-null="false" type="System.String" insert="true" update="true"/>
<property name="Horde" column="HORDE" access="field.pascalcase-underscore" not-null="false" type="System.String" insert="true" update="true"/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
public object GetObjByHQL(string hqlString)
{
object o = null;
IList items = null;
ISession session = SessionProvider.Instance.GetSession();
try
{
IQuery query = session.CreateQuery(hqlString);
items = query.List();
o = items[0];
return o;
}
catch (Exception ex)
{
throw new DataAccessException("Error getting o from items by HQL", ex);
}
finally
{
SessionProvider.Instance.CloseSession();
}
}
Full stack trace of any exception that occurs:
47766 [14] DEBUG NHibernate.SQL (null) - select storageent0_.STORAGE_ID as STORA
GE1_2_, storageent0_.STORAGE_NO as STORAGE2_2_, storageent0_.AREA as AREA2_, sto
rageent0_.SIDE as SIDE2_, storageent0_.SIZ as SIZ2_, storageent0_.TOWER as TOWER
2_, storageent0_.TRAY as TRAY2_, storageent0_.HORDE as HORDE2_ from STORAGE stor
ageent0_ where (storageent0_.STORAGE_NO='A' )and(storageent0_.TOWER=1 )and(stora
geent0_.SIDE='A' )and(storageent0_.AREA=8 )and(storageent0_.TRAY='B' )and(storag
eent0_.SIZ=4 )
NHibernate: select storageent0_.STORAGE_ID as STORAGE1_2_, storageent0_.STORAGE_
NO as STORAGE2_2_, storageent0_.AREA as AREA2_, storageent0_.SIDE as SIDE2_, sto
rageent0_.SIZ as SIZ2_, storageent0_.TOWER as TOWER2_, storageent0_.TRAY as TRAY
2_, storageent0_.HORDE as HORDE2_ from STORAGE storageent0_ where (storageent0_.
STORAGE_NO='A' )and(storageent0_.TOWER=1 )and(storageent0_.SIDE='A' )and(storage
ent0_.AREA=8 )and(storageent0_.TRAY='B' )and(storageent0_.SIZ=4 )
47766 [14] DEBUG NHibernate.Connection.DriverConnectionProvider (null) - Obtaini
ng IDbConnection from Driver
47766 [14] DEBUG NHibernate.AdoNet.AbstractBatcher (null) - Opened IDataReader,
open IDataReaders: 1
47766 [14] DEBUG NHibernate.Loader.Loader (null) - processing result set
47813 [14] DEBUG NHibernate.Loader.Loader (null) - done processing result set (0
rows)
47813 [14] DEBUG NHibernate.AdoNet.AbstractBatcher (null) - Closed IDataReader,
open IDataReaders :0
47829 [14] DEBUG NHibernate.AdoNet.AbstractBatcher (null) - Closed IDbCommand, o
pen IDbCommands: 0
47829 [14] DEBUG NHibernate.AdoNet.ConnectionManager (null) - aggressively relea
sing database connection
47829 [14] DEBUG NHibernate.Connection.ConnectionProvider (null) - Closing conne
ction
47829 [14] DEBUG NHibernate.Loader.Loader (null) - total objects hydrated: 0
47829 [14] DEBUG NHibernate.Engine.StatefulPersistenceContext (null) - initializ
ing non-lazy collections
47829 [14] DEBUG NHibernate.AdoNet.ConnectionManager (null) - after autocommit
47829 [14] DEBUG NHibernate.Impl.SessionImpl (null) - transaction completion
47829 [14] DEBUG NHibernate.AdoNet.ConnectionManager (null) - aggressively relea
sing database connection
289114 [14] DEBUG NHibernate.Connection.DriverConnectionProvider (null) - Obtain
ing IDbConnection from Driver
Name and version of the database you are using:
Oracle 10g
The generated SQL (show_sql=true):
select storageent0_.STORAGE_ID as STORAGE1_2_, storageent0_.STORAGE_
NO as STORAGE2_2_, storageent0_.AREA as AREA2_, storageent0_.SIDE as SIDE2_, sto
rageent0_.SIZ as SIZ2_, storageent0_.TOWER as TOWER2_, storageent0_.TRAY as TRAY
2_, storageent0_.HORDE as HORDE2_ from STORAGE storageent0_ where (storageent0_.
STORAGE_NO='A' )and(storageent0_.TOWER=1 )and(storageent0_.SIDE='A' )and(storage
ent0_.AREA=8 )and(storageent0_.TRAY='B' )and(storageent0_.SIZ=4 )
|