-->
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: hql named parameters scary buggy
PostPosted: Wed Jun 22, 2011 7:46 pm 
Newbie

Joined: Wed Jun 22, 2011 7:31 pm
Posts: 1
I have attempted to use an HQL query with named parameters. The query is quite complicated, something like this
Code:
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

PS. I am using version 3.1.0.


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.