ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilles Schlienger <s_gi...@yahoo.com>
Subject Dynamic request with null values and AND
Date Mon, 03 Mar 2008 18:14:26 GMT
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

>>> Here is my query:

<select id="selectRechercheUtilisateurs"
        parameterClass="xxx.xxx.xxx.xxx.recherche.RechercheUtilisateur" resultMap="utilisateurResultMap">
            select *
            from TABLE_1,TABLE_2
                <isNotNull prepend="AND" property="cabinetId">
                    RTC_FK_CABINET_CBT_ID = #cabinetId#
                    AND RTC_FK_UTILISATEUR_USR_ID = USR_ID
            and USR_FK_CRCC_CRG_ID = CRG_ID

Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail http://mail.yahoo.fr

View raw message