cancel
Showing results for 
Search instead for 
Did you mean: 

NHibernate issue with parameters... named queries as well

Former Member
0 Kudos
5,406

Hi,

In addition to my previously posted question

http://sqlanywhere-forum.sap.com/questions/11380/nhibernate-issue-with-parameters

There seems to be a possible related issue with named query parameters. I have tried very simple query examples with a parameter and the following rig: NHibernate-3.3.0.GA, SybaseSQLAnywhere12Driver, SybaseSQLAnywhere12Dialect, and iAnywhere.Data.SQLAnywhere.v4.0. It is worth noting that this same error also occurs with NHibernate-3.3.0.CR1:

NHibernate.Exceptions.GenericADOException was unhandled Message=could not execute query [ select fxir. into #FX_RATE from FX_RATE fxir inner join (select FromCcy, ToCcy, Source, max(effDate) maxEffDate from FX_RATE where Status <> 'EXCEPTION' and EffDate <= ? and Type = 0 group by FromCcy, ToCcy, Source) C on C.FromCcy = fxir.FromCcy and C.ToCcy = fxir.ToCcy and C.Source = fxir.Source and C.maxEffDate = fxir.EffDate where fxir.Type = 0 and fxir.Status <> 'EXCEPTION' and fxir.Version = (select max(fx2.Version) from FX_RATE fx2 where fx2.ID = fxir.ID) ] Positional parameters: #0>5/4/2012 9:10:39 AM [SQL: select fxir. into #FX_RATE from FX_RATE fxir inner join (select FromCcy, ToCcy, Source, max(effDate) maxEffDate from FX_RATE where Status <> 'EXCEPTION' and EffDate <= ? and Type = 0 group by FromCcy, ToCcy, Source) C on C.FromCcy = fxir.FromCcy and C.ToCcy = fxir.ToCcy and C.Source = fxir.Source and C.maxEffDate = fxir.EffDate where fxir.Type = 0 and fxir.Status <> 'EXCEPTION' and fxir.Version = (select max(fx2.Version) from FX_RATE fx2 where fx2.ID = fxir.ID)] Source=NHibernate SqlString=select fxir.* into #FX_RATE from FX_RATE fxir inner join (select FromCcy, ToCcy, Source, max(effDate) maxEffDate from FX_RATE where Status <> 'EXCEPTION' and EffDate <= ? and Type = 0 group by FromCcy, ToCcy, Source) C on C.FromCcy = fxir.FromCcy and C.ToCcy = fxir.ToCcy and C.Source = fxir.Source and C.maxEffDate = fxir.EffDate where fxir.Type = 0 and fxir.Status <> 'EXCEPTION' and fxir.Version = (select max(fx2.Version) from FX_RATE fx2 where fx2.ID = fxir.ID) StackTrace: at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) in C:OpenSourceNHibernate-3.3.0.GA-srcsrcNHibernateLoaderLoader.cs:line 1573 at NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session, QueryParameters queryParameters) in C:OpenSourceNHibernate-3.3.0.GA-srcsrcNHibernateLoaderLoader.cs:line 1472 at NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet1 querySpaces, IType[] resultTypes) in C:\\OpenSource\\NHibernate-3.3.0.GA-src\\src\\NHibernate\\Loader\\Loader.cs:line 1467 at NHibernate.Loader.Custom.CustomLoader.List(ISessionImplementor session, QueryParameters queryParameters) in C:\\OpenSource\\NHibernate-3.3.0.GA-src\\src\\NHibernate\\Loader\\Custom\\CustomLoader.cs:line 276 at NHibernate.Impl.SessionImpl.ListCustomQuery(ICustomQuery customQuery, QueryParameters queryParameters, IList results) in C:\\OpenSource\\NHibernate-3.3.0.GA-src\\src\\NHibernate\\Impl\\SessionImpl.cs:line 2098 at NHibernate.Impl.SessionImpl.List(NativeSQLQuerySpecification spec, QueryParameters queryParameters, IList results) in C:\\OpenSource\\NHibernate-3.3.0.GA-src\\src\\NHibernate\\Impl\\SessionImpl.cs:line 2081 at NHibernate.Impl.SessionImpl.List[T](NativeSQLQuerySpecification spec, QueryParameters queryParameters) in C:\\OpenSource\\NHibernate-3.3.0.GA-src\\src\\NHibernate\\Impl\\SessionImpl.cs:line 2067 at NHibernate.Impl.SqlQueryImpl.List[T]() in C:\\OpenSource\\NHibernate-3.3.0.GA-src\\src\\NHibernate\\Impl\\SqlQueryImpl.cs:line 163 at SwapExtractDAL.NHibernate.Repositories.NHibernateRepository1.GetNamedQueryResultsDateTimeParam(String queryname, DateTime dt) in C:DevelopmentTestSwapExtractGenerator_02SwapExtractDALNHibernateRepositoriesNHibernateRepository.cs:line 93 at SwapExtractBLL.SwapCommonFileExtraction.GetFxRate() in C:DevelopmentTestSwapExtractGenerator_02SwapExtractBLLSwapCommonFileExtraction.cs:line 71 at SwapExtractBLL.SwapCommonFileExtraction..ctor() in C:DevelopmentTestSwapExtractGenerator_02SwapExtractBLLSwapCommonFileExtraction.cs:line 19 at SwapExtractGenerator_02.Program.Main(String[] args) in C:DevelopmentTestSwapExtractGenerator_02SwapExtractGenerator_02Program.cs:line 27 InnerException: System.ArgumentNullException Message=Value cannot be null. Parameter name: key Source=mscorlib ParamName=key StackTrace: at System.Collections.Generic.Dictionary2.FindEntry(TKey key) at System.Collections.Generic.Dictionary2.ContainsKey(TKey key) at Iesi.Collections.Generic.DictionarySet`1.Add(T o) in c:Usersoskar.berggrenDocumentsProjectsnhibernate-core-3srcIesi.CollectionsGenericDictionarySet.cs:line 57 at NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd) in C:OpenSourceNHibernate-3.3.0.GA-srcsrcNHibernateAdoNetAbstractBatcher.cs:line 245 at NHibernate.Loader.Loader.GetResultSet(IDbCommand st, Boolean autoDiscoverTypes, Boolean callable, RowSelection selection, ISessionImplementor session) in C:OpenSourceNHibernate-3.3.0.GA-srcsrcNHibernateLoaderLoader.cs:line 1224 at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) in C:OpenSourceNHibernate-3.3.0.GA-srcsrcNHibernateLoaderLoader.cs:line 421 at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) in C:OpenSourceNHibernate-3.3.0.GA-srcsrcNHibernateLoaderLoader.cs:line 251 at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) in C:OpenSourceNHibernate-3.3.0.GA-srcsrcNHibernateLoaderLoader.cs:line 1564 InnerException:

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

I would disagree that the above is a "simple" example, at least with respect to NHibernate. What problem determination have you done? All of these exceptions appear to be within NHibernate - have you tried to determine what the reason is behind the "cannot execute query" exception in Visual Studio? Does a simpler named query with a single parameter work?

Former Member
0 Kudos

Hi Glen. I meant that I have tried simple queries, in addition to the one I have posted. It is defintely not an issue with Visual Studio. And yes, I have tried a painfully simple query, with the same exact result.

Former Member
0 Kudos

I didn't mean the problem was with Visual Studio. I meant - have you debugged a simple Criteria query through the VS debugger with a debug build of NH3.3.0?

Former Member
0 Kudos

Yes, using the simple Criteria query posted in my other question, I followed the entire progression through NH. It does in fact appear to send the query that is logged. I did not do this for the named query issue, as they appear to be closely related and it is rather time consuming.

Former Member
0 Kudos

However, I should note again that I am new to NH and my debug walk-through may not have revealed a problem there.