1 Reply Latest reply on Mar 19, 2008 11:13 AM by Pete Muir

    Query - one binding per restriction - any reason?

    Alex Savitsky Novice

      Whenever one puts more than one value binding in a Query's restriction, it throws an exception there should be exactly one value binding in a restriction. Now, I was under the impression that this check is there for a good reason - because there's no code to support multiple bindings per restriction. Apparently, I was wrong - the Query DOES support multiple bindings! Or, at least, the following query worked for me (after commenting out the check code, of course):
           



      <framework:entity-query auto-create="true"
           ejbql="FROM ElementUnitMapping m JOIN FETCH m.element.portion.header.act.country"
           name="unitElementMappings"
           order="m.element.portion.header.act.country.name, m.element.portion.header.act.name,
                m.element.portion.refNumber, m.element.sectionSubsection"
           scope="conversation">
           <framework:restrictions>
                <value>m.unit = #{legislationService.viewedUnit}</value>
                <value>(m.element.primaryTheme IN (#{legislationService.themes})
                     OR m.element.secondaryTheme IN (#{legislationService.themes}))</value>
           </framework:restrictions>
      </framework:entity-query>
      




      As you can see, the second restriction has two bindings, yet everything works like a charm - all parameters are properly assigned.


      So, this leaves me puzzled - why the restriction on restrictions (excuse the pun)? Did I simply get lucky, and there are cases where such setup wouldn't work?


      Thanks,


      Alex