Easiest way would be to put it in the SQL using string concatenation. Depending on your database, you want something like


<isNotEmpty property="FirstName" prepend=" and ">FirstName like #FirstName#||'%'</isNotEmpty>



Or
<isNotEmpty property="FirstName" prepend=" and ">FirstName like #FirstName# + '%'</isNotEmpty>


HTH,
Kris

Nilesh Bhattad wrote:

Hello,

Is there a way to change a property value before it is plugged in to the select statement?

<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>

For example, in the above case, when FirstName is present, is there a way to attach ‘%’ at the end of the FirstName’s value and then perform the select operation?

For some reason, in the calling program, I won’t be able to attach ‘%’ at the end of the search fields. Well, somehow I could achieve that before the iBatis call is made, but I’m kindof hesitant to go with that approach. So I was wondering is there any way to handle it in iBatis layer. Any help is highly appreciated.

Thanks

Nilesh

------------------------------------------------------------------------

No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.7.0 - Release Date: 17/01/2005




--
Kris Jenkins
Email:  [EMAIL PROTECTED]
Blog:   http://cafe.jenkster.com/
Wiki:   http://wiki.jenkster.com/



--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.7.0 - Release Date: 17/01/2005



Reply via email to