Boolean algebra:

(A | B) & (C | D) = (A & C) | (A & D) | (B & C) | (B & D)

The second form can be accomplished with the abator where clause.  I
realise that this becomes more complex as more columns are involved,
but it is likely the best you can do with a generalized query by
criteria given iBATIS' current capabilities in dynamic SQL.

Note that abator's selection of AND and OR is arbitrary - it seemed to
me that I chose the most common case.  You could easily add another
SQL clause and switch the AND/OR if you are more likely to AND clauses
to gether rather than OR them.

Jeff Butler


On Tue, Dec 2, 2008 at 10:17 AM,  <[EMAIL PROTECTED]> wrote:
> Thanks a lot...
>
>  But if I want to construct the query such as
>
>   ( Table.columname1="ABC" or Table.columnam1="EFG" )
>
>     and
>
>   (Table.columname2="123" or Table.columname2="456" )
>
> How I should construct this querry.
>
> And also queries become more complex as no of columns goes on
> increasing.
>
>
>
>
>
> -----Original Message-----
> From: Jeff Butler [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, December 02, 2008 9:41 PM
> To: [email protected]
> Subject: Re: Blocking one -help needed on dynamic changing of conjuction
> property
>
> iBATIS does not support changing the XML attributes at runtime.
>
> It looks like you've started with the abator generated where clause.
> You can probably accomplish what you want to do with a little boolean
> algebra and changing the values of the parameter object.
>
> Jeff Butler
>
>
>
>
> On Tue, Dec 2, 2008 at 10:00 AM,  <[EMAIL PROTECTED]> wrote:
>>  HI all,
>>
>>    I am using criteria querry  and following is the where clause for
> the
>> same.
>>
>>   <sql id="Criteria_Where_Clause" >
>>
>>
>>
>>     <iterate property="oredCriteria" conjunction="or" prepend="where"
>> removeFirstPrepend="iterate" >
>>
>>       (
>>
>>       <iterate prepend="and"
> property="oredCriteria[].criteriaWithoutValue"
>> conjunction="and" >
>>
>>         $oredCriteria[].criteriaWithoutValue[]$
>>
>>       </iterate>
>>
>>       <iterate prepend="and"
>> property="oredCriteria[].criteriaWithSingleValue" conjunction="and" >
>>
>>         $oredCriteria[].criteriaWithSingleValue[].condition$
>>
>>           #oredCriteria[].criteriaWithSingleValue[].value#
>>
>>       </iterate>
>>
>>       <iterate prepend="and"
> property="oredCriteria[].criteriaWithListValue"
>> conjunction="and" >
>>
>>         $oredCriteria[].criteriaWithListValue[].condition$
>>
>>         <iterate
> property="oredCriteria[].criteriaWithListValue[].values"
>> open="(" close=")" conjunction="," >
>>
>>           #oredCriteria[].criteriaWithListValue[].values[]#
>>
>>         </iterate>
>>
>>       </iterate>
>>
>>       <iterate prepend="and"
>> property="oredCriteria[].criteriaWithBetweenValue" conjunction="and" >
>>
>>         $oredCriteria[].criteriaWithBetweenValue[].condition$
>>
>>         #oredCriteria[].criteriaWithBetweenValue[].values[0]# and
>>
>>         #oredCriteria[].criteriaWithBetweenValue[].values[1]#
>>
>>       </iterate>
>>
>>       )
>>
>>     </iterate>
>>
>>   I want to dynamically change the value of conjunction with "OR" and
> "AND"
>> .
>>
>>   I am constructing and passing the criteria object here to this where
>> clause. I have tried with $ $ and # # but it is not working .
>>
>>  can any body please help me.
>>
>> Regards
>>
>> Yuvraj
>>
>>
>
>
>

Reply via email to