-->
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.  [ 3 posts ] 
Author Message
 Post subject: SetMaxResults bug
PostPosted: Tue Aug 26, 2008 5:20 am 
Newbie

Joined: Wed Jan 11, 2006 10:28 am
Posts: 19
Location: Fano, Italy
Hibernate version: 2.0.0 GA
I'm using NHibernate 2.0.0 with SQL Server 2005 and 2005 dialect and I've some issues that was also il 1.2.0 release.
using a sample IQuery for fetch records all works well, but if i specify IQuery.SetMaxResults i receive an "AdoNetException: could not execute query".

This is the broken hql, using IQuery.SetFirstResult(0) and IQuery.SetMaxResults(98):
SELECT TOP 99 idClassT1_1_, Descrizi2_1_, NoLinee1_, Tipo1_, Tariffa1_, TipoLinea1_, DataIniz7_1_, DataFine8_1_, CodIva1_, Descriz10_1_, Descriz11_1_, Descriz12_1_, NoLinee13_1_, Tipo14_1_, Tariffa15_1_, TipoLinea16_1_, DataIni17_1_, DataFin18_1_, CodIva19_1_, Descriz20_1_, Descriz21_1_, Descriz22_1_, NoLinee23_1_, Tipo24_1_, Tariffa25_1_, TipoLinea26_1_, DataIni27_1_, DataFin28_1_, CodIva29_1_, Descriz30_1_, Descriz31_1_, Descriz32_1_, NoLinee33_1_, Tipo34_1_, Tariffa35_1_, TipoLinea36_1_, DataIni37_1_, DataFin38_1_, CodIva39_1_, Descriz40_1_, Descriz41_1_, Descriz42_1_, NoLinee43_1_, Tipo44_1_, Tariffa45_1_, TipoLinea46_1_, DataIni47_1_, DataFin48_1_, CodIva49_1_, Descriz50_1_, Descriz51_1_ FROM (SELECT ROW_NUMBER() OVER(ORDER BY __hibernate_sort_expr_0__) as row, query.idClassT1_1_, query.Descrizi2_1_, query.NoLinee1_, query.Tipo1_, query.Tariffa1_, query.TipoLinea1_, query.DataIniz7_1_, query.DataFine8_1_, query.CodIva1_, query.Descriz10_1_, query.Descriz11_1_, query.Descriz12_1_, query.NoLinee13_1_, query.Tipo14_1_, query.Tariffa15_1_, query.TipoLinea16_1_, query.DataIni17_1_, query.DataFin18_1_, query.CodIva19_1_, query.Descriz20_1_, query.Descriz21_1_, query.Descriz22_1_, query.NoLinee23_1_, query.Tipo24_1_, query.Tariffa25_1_, query.TipoLinea26_1_, query.DataIni27_1_, query.DataFin28_1_, query.CodIva29_1_, query.Descriz30_1_, query.Descriz31_1_, query.Descriz32_1_, query.NoLinee33_1_, query.Tipo34_1_, query.Tariffa35_1_, query.TipoLinea36_1_, query.DataIni37_1_, query.DataFin38_1_, query.CodIva39_1_, query.Descriz40_1_, query.Descriz41_1_, query.Descriz42_1_, query.NoLinee43_1_, query.Tipo44_1_, query.Tariffa45_1_, query.TipoLinea46_1_, query.DataIni47_1_, query.DataFin48_1_, query.CodIva49_1_, query.Descriz50_1_, query.Descriz51_1_, query.__hibernate_sort_expr_0__ FROM (select classtest0x0_.idClassTest as idClassT1_1_, classtest0x0_.Descrizione as Descrizi2_1_, classtest0x0_.NoLinee as NoLinee1_, classtest0x0_.Tipo as Tipo1_, classtest0x0_.Tariffa as Tariffa1_, classtest0x0_.TipoLinea as TipoLinea1_, classtest0x0_.DataInizioValidita as DataIniz7_1_, classtest0x0_.DataFineValidita as DataFine8_1_, classtest0x0_.CodIva as CodIva1_, classtest0x0_.Descrizione1 as Descriz10_1_, classtest0x0_.Descrizione2 as Descriz11_1_, classtest0x0_.Descrizione01 as Descriz12_1_, classtest0x0_.NoLinee01 as NoLinee13_1_, classtest0x0_.Tipo01 as Tipo14_1_, classtest0x0_.Tariffa01 as Tariffa15_1_, classtest0x0_.TipoLinea01 as TipoLinea16_1_, classtest0x0_.DataInizioValidita01 as DataIni17_1_, classtest0x0_.DataFineValidita01 as DataFin18_1_, classtest0x0_.CodIva01 as CodIva19_1_, classtest0x0_.Descrizione101 as Descriz20_1_, classtest0x0_.Descrizione201 as Descriz21_1_, classtest0x0_.Descrizione02 as Descriz22_1_, classtest0x0_.NoLinee02 as NoLinee23_1_, classtest0x0_.Tipo02 as Tipo24_1_, classtest0x0_.Tariffa02 as Tariffa25_1_, classtest0x0_.TipoLinea02 as TipoLinea26_1_, classtest0x0_.DataInizioValidita02 as DataIni27_1_, classtest0x0_.DataFineValidita02 as DataFin28_1_, classtest0x0_.CodIva02 as CodIva29_1_, classtest0x0_.Descrizione102 as Descriz30_1_, classtest0x0_.Descrizione202 as Descriz31_1_, classtest0x0_.Descrizione03 as Descriz32_1_, classtest0x0_.NoLinee03 as NoLinee33_1_, classtest0x0_.Tipo03 as Tipo34_1_, classtest0x0_.Tariffa03 as Tariffa35_1_, classtest0x0_.TipoLinea03 as TipoLinea36_1_, classtest0x0_.DataInizioValidita03 as DataIni37_1_, classtest0x0_.DataFineValidita03 as DataFin38_1_, classtest0x0_.CodIva03 as CodIva39_1_, classtest0x0_.Descrizione103 as Descriz40_1_, classtest0x0_.Descrizione203 as Descriz41_1_, classtest0x0_.Descrizione04 as Descriz42_1_, classtest0x0_.NoLinee04 as NoLinee43_1_, classtest0x0_.Tipo04 as Tipo44_1_, classtest0x0_.Tariffa04 as Tariffa45_1_, classtest0x0_.TipoLinea04 as TipoLinea46_1_, classtest0x0_.DataInizioValidita04 as DataIni47_1_, classtest0x0_.DataFineValidita04 as DataFin48_1_, classtest0x0_.CodIva04 as CodIva49_1_, classtest0x0_.Descrizione104 as Descriz50_1_, classtest0x0_.Descrizione204 as Descriz51_1_, classtest0x0_.idClassTest as __hibernate_sort_expr_0__ from ClassTestTable01 classtest0x0_) query ) page WHERE page.row > 1 ORDER BY __hibernate_sort_expr_0__

The same query without limit instructions works well:
select classtest0x0_.idClassTest as idClassT1_1_, classtest0x0_.Descrizione as Descrizi2_1_, classtest0x0_.NoLinee as NoLinee1_, classtest0x0_.Tipo as Tipo1_, classtest0x0_.Tariffa as Tariffa1_, classtest0x0_.TipoLinea as TipoLinea1_, classtest0x0_.DataInizioValidita as DataIniz7_1_, classtest0x0_.DataFineValidita as DataFine8_1_, classtest0x0_.CodIva as CodIva1_, classtest0x0_.Descrizione1 as Descriz10_1_, classtest0x0_.Descrizione2 as Descriz11_1_, classtest0x0_.Descrizione01 as Descriz12_1_, classtest0x0_.NoLinee01 as NoLinee13_1_, classtest0x0_.Tipo01 as Tipo14_1_, classtest0x0_.Tariffa01 as Tariffa15_1_, classtest0x0_.TipoLinea01 as TipoLinea16_1_, classtest0x0_.DataInizioValidita01 as DataIni17_1_, classtest0x0_.DataFineValidita01 as DataFin18_1_, classtest0x0_.CodIva01 as CodIva19_1_, classtest0x0_.Descrizione101 as Descriz20_1_, classtest0x0_.Descrizione201 as Descriz21_1_, classtest0x0_.Descrizione02 as Descriz22_1_, classtest0x0_.NoLinee02 as NoLinee23_1_, classtest0x0_.Tipo02 as Tipo24_1_, classtest0x0_.Tariffa02 as Tariffa25_1_, classtest0x0_.TipoLinea02 as TipoLinea26_1_, classtest0x0_.DataInizioValidita02 as DataIni27_1_, classtest0x0_.DataFineValidita02 as DataFin28_1_, classtest0x0_.CodIva02 as CodIva29_1_, classtest0x0_.Descrizione102 as Descriz30_1_, classtest0x0_.Descrizione202 as Descriz31_1_, classtest0x0_.Descrizione03 as Descriz32_1_, classtest0x0_.NoLinee03 as NoLinee33_1_, classtest0x0_.Tipo03 as Tipo34_1_, classtest0x0_.Tariffa03 as Tariffa35_1_, classtest0x0_.TipoLinea03 as TipoLinea36_1_, classtest0x0_.DataInizioValidita03 as DataIni37_1_, classtest0x0_.DataFineValidita03 as DataFin38_1_, classtest0x0_.CodIva03 as CodIva39_1_, classtest0x0_.Descrizione103 as Descriz40_1_, classtest0x0_.Descrizione203 as Descriz41_1_, classtest0x0_.Descrizione04 as Descriz42_1_, classtest0x0_.NoLinee04 as NoLinee43_1_, classtest0x0_.Tipo04 as Tipo44_1_, classtest0x0_.Tariffa04 as Tariffa45_1_, classtest0x0_.TipoLinea04 as TipoLinea46_1_, classtest0x0_.DataInizioValidita04 as DataIni47_1_, classtest0x0_.DataFineValidita04 as DataFin48_1_, classtest0x0_.CodIva04 as CodIva49_1_, classtest0x0_.Descrizione104 as Descriz50_1_, classtest0x0_.Descrizione204 as Descriz51_1_ from ClassTestTable01 classtest0x0_ order by classtest0x0_.idClassTest ASC

Any suggestion about this issue?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 26, 2008 10:04 am 
Newbie

Joined: Wed Jan 11, 2006 10:28 am
Posts: 19
Location: Fano, Italy
I've take a look at the log messages and i see something like:
"System.Data.SqlClient.SqlException: 'ROW_NUMBER' is not a recognized function name.
Line 1: Incorrect syntax near 'query'.
in System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
in System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
in System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
in System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
in System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
in System.Data.SqlClient.SqlDataReader.get_MetaData()
in System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
in System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
in System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
in System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
in System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
in System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
in System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
in NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd)
in NHibernate.Loader.Loader.GetResultSet(IDbCommand st, Boolean autoDiscoverTypes, Boolean callable, RowSelection selection, ISessionImplementor session)
WARN - System.Data.SqlClient.SqlException: 'ROW_NUMBER' is not a recognized function name.
Line 1: Incorrect syntax near 'query'.
in System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
in System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
in System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
in System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
in System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
in System.Data.SqlClient.SqlDataReader.get_MetaData()
in System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
in System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
in System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
in System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
in System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
in System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
in System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
in NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd)
in NHibernate.Loader.Loader.GetResultSet(IDbCommand st, Boolean autoDiscoverTypes, Boolean callable, RowSelection selection, ISessionImplementor session)
ERROR - 'ROW_NUMBER' is not a recognized function name."

So, ROW_NUMBER looks not supported... so looks like a SQL 2005 problem... I need to investigate 'cause I'm not a DB admin...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 26, 2008 10:12 am 
Newbie

Joined: Wed Jan 11, 2006 10:28 am
Posts: 19
Location: Fano, Italy
Ok, so the SQL Server Instance that I'm pretty sure was a Sql2005 instance, actually is a Sql2000 instance :(
using Sql2000 dialect instead of Sql"005 restores correct behavior.
Sorry for the time lost to anyone reading this post


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

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.