named parameters are not set properly in hql query

19 views
Skip to first unread message

costa

unread,
Jun 23, 2011, 12:37:28 PM6/23/11
to nhusers
I am using version 3.1.0.

I have attempted to use an HQL query with named parameters. The query
is quite complicated, something like this:

select
v.VariableId as VariableId,
vv.VariableValueId as VariableValueId,
case
when vv.VariableValueId is not null then
case
when vst.ValueSourceTypeId = :autoLoad then vv.Value
else null
end
else null
end as Formula
case
when vv.VariableValueId is not null then
case
when vv.Value is null then v.SimulationValue
when vst.ValueSourceTypeId = :autoLoad then null
else vv.Value
end
when v.IsFormulaBased = 0 then v.SimulationValue
else null
end as Value,
case
when (vv.VariableValueId is not null and vst.ValueSourceTypeId
= :autoLoad) or (vv.VariableValueId is null and v.IsFormulaBased = 1)
then
:value1
else
:value2
end as EvaluationStatus
from Variable v
left join v.Formula f
left join v.VariableValues vv with vv.Organization.OrganizationId
= :organizationId and vv.TimePeriod.TimePeriodId = :timePeriodId
left join vv.ValueSourceType vst
left join vv.CurrentOverride ov
where v.Frequency.FrequencyId = (select tp.Frequency.FrequencyId
from TimePeriod tp where tp.TimePeriodId = :timePeriodId)


I set the parameters using SetParameter calls.

When the query gets translated to sql and executed, the parameters are
completely f****d up. I attempted to debug and I noticed that the
query gets translated to a form that uses the jdbc syntax with
question marks as parameter placeholders but I didn't have time to dig
deeper and see exactly where things get screwed up.

Please note that some parameters are used multiple times. Is that
allowed? I even tried to have unique parameters names but, still, the
parameter values were not assigned correctly.

Did anyone come across this problem? To me this is a major bug and I
am very surprised by this behavior. Unless I am missing something
obvious - maybe a setting somewhere.

Please note that the hql query is built in c# code and I ended up
using the good old String.Format. I didn't attempt to use named
queries.

Thanks

Fabio Maulo

unread,
Jun 27, 2011, 9:55:27 AM6/27/11
to nhu...@googlegroups.com
NH3.2 has the parameters management completely rewrote fixing lot of issues and introducing new features (even if not so visible to everybody ;)  

costa

unread,
Jul 4, 2011, 7:56:28 PM7/4/11
to nhusers
Thank you, Fabio. As soon as it comes out I will give it a try.
Reply all
Reply to author
Forward
0 new messages