I have a table called "users" with following columns userid,name,gender,department,managerid....
I wanted to do this query but was having 2 issues
1. <> in line 4 is is causing problem, which is due to to the XML. I need to use but was not able to get things going even after some permutations.
2. the check department = 'engineering' needs to be done only if the map passed contains department. so this needs to be dynamic.
Can some one scribble as to how I could get this done in Ibatis. thanks for your help !!!
select * from users
where userid=#userid#
and gender = 'm'
and (managerid ISNULL OR managerid <> #mgrid#)
and department = 'engineering'
I tried this but did not work ....any help??
<select id="getEmployees" parameterClass="java.util.HashMap" resultMap="empResultMap">
<![CDATA[
select * from users
where userid=#userid#
and gender = 'm'
and (managerid ISNULL OR managerid <> #mgrid#)
<dynamic>
<isNotEmpty property="mgrid">
( AND department = #mgrid# )
</isNotEmpty>
</dynamic>
]]>
</select>