ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nilesh Bhattad" <nil...@outlinesys.com>
Subject Qns abt using <isNotEmpty/> inside <select/>
Date Tue, 18 Jan 2005 16:02:05 GMT
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

Mime
View raw message