Hi all,
I'm using iBATIS in my application (and I love it) and my question is about
using dynamic requests for an optimized research SQL request.
I want to do the following:
- if parameters are not null have dynamic WHERE clauses merged with my join
criterias
- if parameters are null, have just my join criterias
My problem is that if all my dynamic attributes are null, I get a query in the
form: SELECT XXX WHERE AND YYY and the query WHERE AND does not work...
Would there be any clean way to ovoid this ?
Thanks in advance
Gilles
>>> Here is my query:
<select id="selectRechercheUtilisateurs"
parameterClass="xxx.xxx.xxx.xxx.recherche.RechercheUtilisateur"
resultMap="utilisateurResultMap">
select *
from TABLE_1,TABLE_2
where
<dynamic>
<isNotNull prepend="AND" property="cabinetId">
RTC_FK_CABINET_CBT_ID = #cabinetId#
AND RTC_FK_UTILISATEUR_USR_ID = USR_ID
</isNotNull>
</dynamic>
and RCC_FK_UTILISATEUR_USR_ID = USR_ID
and USR_FK_CRCC_CRG_ID = CRG_ID
</select>
_____________________________________________________________________________
Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail
http://mail.yahoo.fr