-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Get result in sql and exception in HQL
PostPosted: Mon Jul 28, 2008 9:14 am 
Newbie

Joined: Thu May 08, 2008 3:14 am
Posts: 16
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 )


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.