Thanks Tim!! I changed the
<select/> as below and all possible conditions worked fine… <select id="search"
parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
select ConsultantId, BlackListed, FirstName, LastName, HomeTelephone, EmailAddress, InterviewGrade, TotalYrsOfExp from Consultant
<dynamic
prepend=" where
">
<isNotEmpty property="FirstName" prepend="
and ">FirstName like #FirstName#</isNotEmpty>
<isNotEmpty property="LastName" prepend="
and ">LastName like #LastName#</isNotEmpty>
<isNotEmpty property="ActiveInactive" prepend="
and ">ActiveInactive like #ActiveInactive#</isNotEmpty> </dynamic>
order by FirstName, LastName
</select> iBatis rocks !! ~ Nilesh -----Original Message----- There's a simple problem. If you look at the docs..
there is another statement that you can use to wrap what you have called: <dynamic
prepend="WHERE"> if you add that instead
of your 'where' it will be okay. -Tim From: Nilesh
Bhattad [mailto:[EMAIL PROTECTED] 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 |
- Qns abt using <isNotEmpty/> inside <select/> Nilesh Bhattad
- RE: Qns abt using <isNotEmpty/> inside <selec... Chen, Tim
- Nilesh Bhattad