nhibernate-core icon indicating copy to clipboard operation
nhibernate-core copied to clipboard

NHibernate producing query without column in SELECT clause.

Open gaurav26111985 opened this issue 2 years ago • 3 comments

Issue - NHibernate producing query without column in SELECT clause
Question 1- Under what conditions can this occurs ? Question 2- Could this be a Bug ?

Stack Trace -

NHibernate.Exceptions.GenericADOException: Failed to execute multi criteria[SQL: SELECT  FROM [dbo].[VwTemplateSearcher] this_ ORDER BY CURRENT_TIMESTAMP OFFSET 0 ROWS FETCH FIRST ? ROWS ONLY;  SELECT count(*) as y0_ FROM [dbo].[VwTemplateSearcher] this_;  ] ---> System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'FROM'.  Invalid usage of the option FIRST in the FETCH statement.    
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)    
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)    
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)    
   at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()    
   at System.Data.SqlClient.SqlDataReader.get_MetaData()    
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)    
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)    
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)    
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)    
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)    
   at NHibernate.AdoNet.AbstractBatcher.DoExecuteReader(DbCommand cmd)    
   at NHibernate.AdoNet.AbstractBatcher.ExecuteReader(DbCommand cmd)    
   at NHibernate.Driver.BatcherDataReaderWrapper.Create(IBatcher batcher, DbCommand command)    
   at NHibernate.Driver.BasicResultSetsCommand.GetReader(Nullable`1 commandTimeout)    
   at NHibernate.Impl.MultiCriteriaImpl.GetResultsFromDatabase(IList results)     
   --- End of inner exception stack trace ---    
   at NHibernate.Impl.MultiCriteriaImpl.GetResultsFromDatabase(IList results)    
   at NHibernate.Impl.MultiCriteriaImpl.List()    
   at Aon.ATD.Repository.BaseQueue.BaseQueueDataAccess.GetData(ATDQueryObject atdQueryObject)    
   at Aon.ATD.BusinessLayer.BaseQueue.BaseRequestViewManager.GetRequestViewData(ATDQueryObject atdQueryObject)

gaurav26111985 avatar Jun 29 '23 16:06 gaurav26111985

It is a bug, be we cannot tell if that is a user code bug or a NHibernate bug with this information.

Can you check this with a test case?

See Contributing. (Also worth reading, The best way to get NHibernate community support ? Submit precise description of the problem.)

fredericDelaporte avatar Jun 29 '23 18:06 fredericDelaporte

This is very intermittent Issue. There is very difficult to run exact test cases of this issue.

gaurav26111985 avatar Jul 05 '23 15:07 gaurav26111985

Looks like some old NHibernate version is used as MultiCriteriaImpl is obsoleted since v5.2.

bahusoid avatar Jul 05 '23 15:07 bahusoid