Since recently (trunk), now and then queries throw an error that
earlier never did:

        public IList<Category> GetCategoriesOfGroupWithKey(string key)
        {
            var hql =
                "select distinct cats " +
                "from Article as a " +
                "left outer join a.Categories as cats " +
                "where a.ProductGroup.Key = :key " +
                "and a.IsDiscontinued = 0 " +
                "and a.IsActive = 1";

            var list = Session.CreateQuery(hql)
                .SetString("key", key)
                .List<Category>();
            return list;
        }

ADOException

Message:
could not execute query
[ select distinct category2_.CategoryID as CategoryID4_,
category2_.Name as Name4_, category2_.BusinessKey as Business3_4_,
category2_.Description as Descript4_4_, category2_.Visible as
Visible4_ from xxx2.dbo.[Article] article0_ left outer join
xxx2.dbo.ArticleCategory categories1_ on
article0_.ArticleID=categories1_.ArticleID left outer join
xxx2.dbo.Category category2_ on
categories1_.CategoryID=category2_.CategoryID, xxx2.dbo.[ProductGroup]
productgro3_ where (productgro3_.businessk...@p1  and
article0_.ProductGroupID=productgro3_.ProductGroupID)and(article0_.IsDiscontinued=0
)and(article0_.InStock=1 ) ]
  Name:key - Value:adesivos
[SQL: select distinct category2_.CategoryID as CategoryID4_,
category2_.Name as Name4_, category2_.BusinessKey as Business3_4_,
category2_.Description as Descript4_4_, category2_.Visible as
Visible4_ from xxx2.dbo.[Article] article0_ left outer join
xxx2.dbo.ArticleCategory categories1_ on
article0_.ArticleID=categories1_.ArticleID left outer join
xxx2.dbo.Category category2_ on
categories1_.CategoryID=category2_.CategoryID, xxx2.dbo.[ProductGroup]
productgro3_ where (productgro3_.businessk...@p1  and
article0_.ProductGroupID=productgro3_.ProductGroupID)and(article0_.IsDiscontinued=0
)and(article0_.InStock=1 )]


StackTrace:
   at NHibernate.Loader.Loader.DoList(ISessionImplementor session,
QueryParameters queryParameters) in
c:\data\nhibernate\trunk\nhibernate\src\NHibernate\Loader\Loader.cs:line
1713
   at NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor
session, QueryParameters queryParameters) in
c:\data\nhibernate\trunk\nhibernate\src\NHibernate\Loader\Loader.cs:line
1628
   at NHibernate.Loader.Loader.List(ISessionImplementor session,
QueryParameters queryParameters, ISet`1 querySpaces, IType[]
resultTypes) in
c:\data\nhibernate\trunk\nhibernate\src\NHibernate\Loader\Loader.cs:line
1622
   at NHibernate.Hql.Classic.QueryTranslator.List(ISessionImplementor
session, QueryParameters queryParameters) in
c:\data\nhibernate\trunk\nhibernate\src\NHibernate\Hql\Classic\QueryTranslator.cs:line
1287
   at NHibernate.Engine.Query.HQLQueryPlan.PerformList(QueryParameters
queryParameters, ISessionImplementor session, IList results) in
c:\data\nhibernate\trunk\nhibernate\src\NHibernate\Engine\Query\HQLQueryPlan.cs:line
226
   at NHibernate.Impl.SessionImpl.List(String query, QueryParameters
queryParameters, IList results) in
c:\data\nhibernate\trunk\nhibernate\src\NHibernate\Impl\SessionImpl.cs:line
517
   at NHibernate.Impl.SessionImpl.List[T](String query,
QueryParameters parameters) in
c:\data\nhibernate\trunk\nhibernate\src\NHibernate\Impl\SessionImpl.cs:line
496
   at NHibernate.Impl.QueryImpl.List[T]() in
c:\data\nhibernate\trunk\nhibernate\src\NHibernate\Impl\QueryImpl.cs:line
94
   at xxx.Data.ProductGroupDao.GetCategoriesOfGroupWithKey(String key)
in C:\data\xxx\xxx.Data\ProductGroupDao.cs:line 88
   at xxx.Web.Site.MVC.Controllers.ProductGroupsController.DetailByKey(String
key, String[] categoryKeys, Decimal priceRangeUntil, Int32 pageOffset,
Int32 itemsPerPage) in
C:\data\xxx\xxx.Web.Site.MVC\Controllers\ProductGroupsController.cs:line
61
   at xxx.Web.Site.MVC.Controllers.ProductGroupsController.DetailByKey(String
key) in C:\data\xxx\xxx.Web.Site.MVC\Controllers\ProductGroupsController.cs:line
22

Inner exception:

SqlException

Message:
Must declare the scalar variable "@p1".

Does not seem to me I am doing something wrong here. Usually I can fix
that by using positional params, but it's akward, nonetheless.
Is this expected behavior? If I use this query directly in the
console, it works just nicely. Mind that it is angry about some
_scalar_ variable...

--~--~---------~--~----~------------~-------~--~----~
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