Quantcast

isPropertyAvailable/isNotPropertyAvailable

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

isPropertyAvailable/isNotPropertyAvailable

Andreas Markitanis
Hi

I've found an old thread about this and Jeff Butler said the
following:

"It's because we switched to OGNL for evaluating expressions.  If you
are using a Map for your parameter object, you can use the
containsKey() method to check for a property in the Map.  I think
that
was the most likely use of isPropertyAvailable anyway."


So my question is the following: If the parameter type is a Map/
HashMap...and you want to check if a property is contained as a key in
the hashmap...what argument name would you use for the map in dynamic
sql?

        <if test="!map.containsKey(clusterId)">
          <if test="clusterId != null">
                and (fac.mdr_id = #{clusterId} OR (fac.mdr_id IS NULL
AND fac.pndg_mdr_id = #{clusterId}))
          </if>

So is there a special word I could use for map.containsKey(...)?

Thanks
Andreas
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: isPropertyAvailable/isNotPropertyAvailable

Jeff Butler
Try

 <if test="_parameter.containsKey('clusterId')">

Jeff Butler


On Tue, Feb 14, 2012 at 10:54 AM, kkudi <[hidden email]> wrote:

> Hi
>
> I've found an old thread about this and Jeff Butler said the
> following:
>
> "It's because we switched to OGNL for evaluating expressions.  If you
> are using a Map for your parameter object, you can use the
> containsKey() method to check for a property in the Map.  I think
> that
> was the most likely use of isPropertyAvailable anyway."
>
>
> So my question is the following: If the parameter type is a Map/
> HashMap...and you want to check if a property is contained as a key in
> the hashmap...what argument name would you use for the map in dynamic
> sql?
>
>        <if test="!map.containsKey(clusterId)">
>          <if test="clusterId != null">
>                and (fac.mdr_id = #{clusterId} OR (fac.mdr_id IS NULL
> AND fac.pndg_mdr_id = #{clusterId}))
>          </if>
>
> So is there a special word I could use for map.containsKey(...)?
>
> Thanks
> Andreas
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: isPropertyAvailable/isNotPropertyAvailable

Andreas Markitanis
Hi Jeff

Thanks for your response, it worked.

One last thing:

if in your parapameter map you have

parameter_map.put("sortBy", "portfolio_id");

For string comparisons would you just simply do...

            <if test="sortBy == 'portfolio_id'">
                order by p_portfolio_id
            </if>

Regards,
Andreas
       
On 14 Feb 2012, at 19:14, Jeff Butler wrote:

> Try
>
> <if test="_parameter.containsKey('clusterId')">
>
> Jeff Butler
>
>
> On Tue, Feb 14, 2012 at 10:54 AM, kkudi <[hidden email]> wrote:
>> Hi
>>
>> I've found an old thread about this and Jeff Butler said the
>> following:
>>
>> "It's because we switched to OGNL for evaluating expressions.  If you
>> are using a Map for your parameter object, you can use the
>> containsKey() method to check for a property in the Map.  I think
>> that
>> was the most likely use of isPropertyAvailable anyway."
>>
>>
>> So my question is the following: If the parameter type is a Map/
>> HashMap...and you want to check if a property is contained as a key in
>> the hashmap...what argument name would you use for the map in dynamic
>> sql?
>>
>>        <if test="!map.containsKey(clusterId)">
>>          <if test="clusterId != null">
>>                and (fac.mdr_id = #{clusterId} OR (fac.mdr_id IS NULL
>> AND fac.pndg_mdr_id = #{clusterId}))
>>          </if>
>>
>> So is there a special word I could use for map.containsKey(...)?
>>
>> Thanks
>> Andreas

Loading...