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