You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Nilesh Bhattad <ni...@outlinesys.com> on 2005/01/18 17:02:05 UTC
Qns abt using inside
Hello,
I'm having some trouble while using <isNotEmpty/> node inside <select/>
Please take a look at below select statement.
<select id="search" parameterClass="java.util.HashMap"
resultClass="java.util.HashMap">
select ConsultantId, BlackListed, FirstName, LastName,
HomeTelephone, EmailAddress, InterviewGrade, TotalYrsOfExp from
Consultant where
<isNotEmpty property="FirstName">FirstName like
#FirstName#</isNotEmpty>
<isNotEmpty property="LastName" prepend=" and ">LastName like
#LastName#</isNotEmpty>
<isNotEmpty property="ActiveInactive" prepend=" and
">ActiveInactive like #ActiveInactive#</isNotEmpty>
order by FirstName, LastName
</select>
The problem with this stmt is if only ActiveInactive is keyed in, the
select stmt is resolved like below -
select ConsultantId, BlackListed, FirstName, LastName, HomeTelephone,
EmailAddress, InterviewGrade, TotalYrsOfExp from Consultant where
and ActiveInactive like ? order by FirstName, LastName
'and' is added in the stmt which makes it invalid query. How do I adjust
the <isNotEmpty/> tags inside <select/> so that it will work for any
combination?
Help, please !
~ Nilesh