|
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 |
|
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 |
|
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 |
| Powered by Nabble | Edit this page |
