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.  [ 3 posts ] 
Author Message
 Post subject: SetParameterList causing a SQL parsing error?
PostPosted: Tue Sep 05, 2006 9:32 pm 
Newbie

Joined: Tue Sep 05, 2006 9:22 pm
Posts: 2
I've got a strange bug... I have a query that looks like this:

Code:
Dictionary<string, QueryNode> keys;

IQuery q = session.CreateQuery("from CalculatedValue cv where " +
                  "cv.State = :state and " +
                  "cv.HierarchyKey in (:keys)" +
                  "cv.Granularity = :granularity and " +
                  "cv.StartTime >= :start and " +
                  "cv.StartTime < :end");

q.SetEnum("state", CalculatedValue.CalculationState.Ready);
q.SetParameterList("keys", keys.Keys);
q.SetEnum("granularity", period);
q.SetDateTime("start", start);
q.SetDateTime("end", end);

IList<CalculatedValue> values = q.List<CalculatedValue>();


When I try to run this, NHibernate drops out with an NHibernate.ADOException "could not execute query."

The SQL string looks like this:
Code:
"select calculated0_.Id as Id, calculated0_.Data as Data61_, calculated0_.Modified as Modified61_, calculated0_.StartTime as StartTime61_, calculated0_.HierarchyKey as Hierarch6_61_, calculated0_.State as State61_, calculated0_.Granularity as Granular7_61_, calculated0_.calculatedvalue_id as calcula12_61_, calculated0_.Created as Created61_, calculated0_.version as version61_, calculated0_.TransactionObjects as Transac10_61_, calculated0_.GlobalId as GlobalId61_ from CalculatedValue calculated0_ where (calculated0_.State=:p00)and(calculated0_.HierarchyKey in(:p10 , :p20 , :p30 , :p40)calculated0_.Granularity=:p50)and(calculated0_.StartTime>=:p60)and(calculated0_.StartTime<:p70)"


The InnerException says "Incorrect syntax near 'calculated0_'" which doesn't really make sense.

If I take out the "cv.HierarchyKey in (:keys)" clause and remove "q.SetParameterList()" then it works....

Am I doing something wrong?

Thanks,
-Tim


Top
 Profile  
 
 Post subject: Re: SetParameterList causing a SQL parsing error?
PostPosted: Wed Sep 06, 2006 1:26 am 
Expert
Expert

Joined: Thu Jan 19, 2006 4:29 pm
Posts: 348
tlyakhov wrote:
I've got a strange bug... I have a query that looks like this:

Code:
                  "cv.HierarchyKey in (:keys)" +
                  "cv.Granularity = :granularity and " +



You have missing "and" between those two conditions.

Gert

_________________
If a reply helps You, rate it!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 06, 2006 5:11 pm 
Newbie

Joined: Tue Sep 05, 2006 9:22 pm
Posts: 2
Oh man, thanks so much. That's what happens when you stare at a chunk of code for two hours.

My apologies for the stupid question.

-Tim


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

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.