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