-->
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.  [ 1 post ] 
Author Message
 Post subject: NHibernate MultiQuery error challenge!
PostPosted: Fri Sep 19, 2008 1:00 pm 
Newbie

Joined: Sat Sep 06, 2008 4:55 pm
Posts: 5
Hi, this multi query issue has me stumped. I've checked the documentation and no one else seems to have this problem which makes me think I am missing something really silly. My queries are fairly simple and I am sure the EmailAddress mapping is ok since I've used it many times before this.

I really appreciate any help

Hibernate version: 1.2.1 AND 2.0.0 GA

Mapping documents:

<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NData.Core" namespace="NData.Entities">

<!--http://ayende.com/Blog/archive/2006/05/02/CombatingTheSelectN1ProblemInNHibernate.aspx-->
<!--http://blogs.hibernatingrhinos.com/nhibernate/archive/2008/04/06/eager-loading-aggregate-with-many-child-collections.aspx-->
<sql-query name="query1">
<return alias="ia" class="EmailAddress" />
SELECT
ia.*
FROM EmailAddresses ia
WHERE ia.Ignore = 0 AND
(
Exists(SELECT top 1 * FROM NewEmployees ecs WHERE ecs.FK_EmailID = ia.ID)
)
AND (ia.LastDateSent IS NULL OR ia.LastDateSent &lt; DATEADD(dd,-7, GetDate()))
</sql-query>

</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():

//this doesn't work
IMultiQuery mquery = session.CreateMultiQuery();
mquery.AddNamedQuery("query1");
Object l = mquery.List();

//this works
IQuery q = m_session.GetNamedQuery("query1");
l = q.List();

Full stack trace of any exception that occurs:

Message

in expected: ia [SELECT
ia.*
FROM EmailAddresses ia
WHERE ia.Ignore = 0 AND
(
Exists(SELECT top 1 * FROM NewEmployees ecs WHERE ecs.FK_EmailID = ia.ID)
)
AND (ia.LastDateSent IS NULL OR ia.LastDateSent &lt; DATEADD(dd,-7, GetDate()))]



Stack trace

at NHibernate.Hql.Classic.FromParser.Token(String token, QueryTranslator q)
at NHibernate.Hql.Classic.ClauseParser.Token(String token, QueryTranslator q)
at NHibernate.Hql.Classic.PreprocessingParser.Token(String token, QueryTranslator q)
at NHibernate.Hql.Classic.ParserHelper.Parse(IParser p, String text, String seperators, QueryTranslator q)
at NHibernate.Hql.Classic.QueryTranslator.Compile()
at NHibernate.Hql.Classic.QueryTranslator.Compile(IDictionary`2 replacements, Boolean scalar)
at NHibernate.Impl.SessionFactoryImpl.GetQuery(String queryString, Boolean shallow, IDictionary`2 enabledFilters)
at NHibernate.Impl.SessionImpl.GetQueries(String query, Boolean scalar)
at NHibernate.Impl.MultiQueryImpl.AggregateQueriesInformation()
at NHibernate.Impl.MultiQueryImpl.get_Parameters()
at NHibernate.Impl.MultiQueryImpl.CreateCombinedQueryParameters()
at NHibernate.Impl.MultiQueryImpl.List()
at NData.DAO.EmailDA.GetPending() in C:\Documents and Settings\joelwenzel\My Documents\Visual Studio 2008\Projects\Northwind5\ClassLibrary1\DataAccess\EmailDA.cs:line 41
at Northwind5.Emailer.SendPendingMail(String templateUrl, delGetUrl getUrl, delEncode encode, delEncode formatText) in C:\Documents and Settings\joelwenzel\My Documents\Visual Studio 2008\Projects\Northwind5\Northwind5\AppCode\Emailer.cs:line 73
at Northwind5.Controllers.InviteController.SendInvitations() in C:\Documents and Settings\joelwenzel\My Documents\Visual Studio 2008\Projects\Northwind5\Northwind5\Controllers\InviteController.cs:line 44
at lambda_method(ExecutionScope , ControllerBase , Object[] )
at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(MethodInfo methodInfo, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClassb.<InvokeActionMethodWithFilters>b__8()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)


Name and version of the database you are using: MS SQL Servcer 2005 Express

Debug level Hibernate log excerpt:


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

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.