I'm running this query <SNIP> and I have an exception.
I can't show you the mapping.
If I change the way I'm querying my domain all work fine.

The exception is a bug or an expected behaviour ?


2009/11/25 Kent Boogaart <[email protected]>

> Hi,
>
> If I use CreateAlias() in conjunction with SetFirstResult() as
> follows:
>
>        var query = session.CreateCriteria<Article>()
>                .SetMaxResults(10)
>                .SetFirstResult(100)
>                .CreateAlias("Places", "place")
>                .CreateAlias("Categories", "category");
>
> I get an exception:
>
>        NHibernate.ADOException : could not execute query
>        [ SELECT <SNIP> ]
>        [SQL: SELECT <SNIP>]
>        ---- System.Data.SqlClient.SqlException : The column 'ArticleId' was
> specified multiple times for 'query'.
>                at NHibernate.Loader.Loader.DoList(ISessionImplementor
> session,
> QueryParameters queryParameters)
>                at
> NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor
> session, QueryParameters queryParameters)
>                at NHibernate.Loader.Loader.List(ISessionImplementor
> session,
> QueryParameters queryParameters, ISet`1 querySpaces, IType[]
> resultTypes)
>                at NHibernate.Impl.SessionImpl.List(CriteriaImpl criteria,
> IList
> results)
>                at NHibernate.Impl.CriteriaImpl.List(IList results)
>                at NHibernate.Impl.CriteriaImpl.List[T]()
>                ----- Inner Stack Trace -----
>                at System.Data.SqlClient.SqlConnection.OnError(SqlException
> exception, Boolean breakConnection)
>                at
> System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
> exception, Boolean breakConnection)
>                at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning
> (TdsParserStateObject stateObj)
>                at System.Data.SqlClient.TdsParser.Run(RunBehavior
> runBehavior,
> SqlCommand cmdHandler, SqlDataReader dataStream,
> BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
> stateObj)
>                at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
>                at System.Data.SqlClient.SqlDataReader.get_MetaData()
>                at System.Data.SqlClient.SqlCommand.FinishExecuteReader
> (SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
>                at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds
> (CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean
> returnStream, Boolean async)
>                at
> System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
> cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
> method, DbAsyncResult result)
>                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 System.Data.SqlClient.SqlCommand.ExecuteDbDataReader
> (CommandBehavior behavior)
>                at
> System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader
> ()
>                at
> NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd)
>                at NHibernate.Loader.Loader.GetResultSet(IDbCommand st,
> Boolean
> autoDiscoverTypes, Boolean callable, RowSelection selection,
> ISessionImplementor session)
>                at NHibernate.Loader.Loader.DoQuery(ISessionImplementor
> session,
> QueryParameters queryParameters, Boolean returnProxies)
>                at
> NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections
> (ISessionImplementor session, QueryParameters queryParameters, Boolean
> returnProxies)
>                at NHibernate.Loader.Loader.DoList(ISessionImplementor
> session,
> QueryParameters queryParameters)
>
> The problem is that multiple columns in the sub-select are assigned
> the same name ('ArticleId' in the above case).
>
> If I manually force an outer join:
>
>        var query = session.CreateCriteria<Article>()
>                .SetMaxResults(10)
>                .SetFirstResult(100)
>                .CreateAlias("Places", "place", JoinType.LeftOuterJoin)
>                .CreateAlias("Categories", "category",
> JoinType.LeftOuterJoin);
>
> Then the query succeeds.
>
> Is this a bug or expected behavior?
>
> Thanks,
> Kent
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>
>


-- 
Fabio Maulo

--

You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.


Reply via email to