You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Ibatis534 <ib...@mailinator.com> on 2008/08/12 06:23:04 UTC

Complex Abator Query

I have question relating to using the Abator Example Class with Java 5.

How would create the following query using a java5 example class:

if (bool1 not true && date1 is null & 
    ((date2 between testdate1 and testdate2 and string1 is null)or (date3
between testdate1 and testdate2 and string2 is null))

My attempts aren't going so well.

TIA
-- 
View this message in context: http://www.nabble.com/Complex-Abator-Query-tp18937755p18937755.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: Complex Abator Query

Posted by je...@gmail.com.
What you're experiencing is really a limitation in iBATIS 2 dynamic
SQL. The legacy generator generated *a lot* of code and still was
pretty limited in function. The new generators generate better code
IMHO, and you really can create very flexible WHERE clauses. There are
still some inefficiencies as you've seen. But I believe that the new
generators are the best option, given the limitations of iBATIS 2.

I have high hopes for better, more flexible, options when iBATIS 3
becomes available.

Jeff Butler

On 8/13/08, Ibatis534 <ib...@mailinator.com> wrote:
>
> Thanks.
>
> Can I make a feature request that enables Example Classes to construct
> queries in a more dynamic way. It would be nice to be able to combine
> clauses as either 'OR' or 'AND' like
>
>
> criteria1 = example.createCriteria().andField1EqualTo(testValue);
> criteria2 = example.createCriteria().andField2IEqualTo(testValue2);
>
> example.andCriteria(criteria1);
> if(testValue3 > 5)
>     example.andCriteria(criterial2);
> else
>     example.orCriteria(criterial2);
>
>
> I guess I'm looking for some way to combine the power of the Java5 Generator
> with the flexibility of the Legacy Generator.
> --
> View this message in context:
> http://www.nabble.com/Complex-Abator-Query-tp18937755p18957341.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>

Re: Complex Abator Query

Posted by Ibatis534 <ib...@mailinator.com>.
Thanks.

Can I make a feature request that enables Example Classes to construct
queries in a more dynamic way. It would be nice to be able to combine
clauses as either 'OR' or 'AND' like 


criteria1 = example.createCriteria().andField1EqualTo(testValue); 
criteria2 = example.createCriteria().andField2IEqualTo(testValue2); 

example.andCriteria(criteria1);
if(testValue3 > 5)
    example.andCriteria(criterial2);
else
    example.orCriteria(criterial2);
   

I guess I'm looking for some way to combine the power of the Java5 Generator
with the flexibility of the Legacy Generator.
-- 
View this message in context: http://www.nabble.com/Complex-Abator-Query-tp18937755p18957341.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: Complex Abator Query

Posted by Jeff Butler <je...@gmail.com>.
Ibator where clauses are always in this form:

(x && y && z) || (a && b && c)

You can use boolean algebra to refactor your query into something that can
be accomplished in ibator.  For example:

(bool1 not true && date1 is null && date2 between testdate1 and testdate2 &&
string1 is null) ||
(bool1 not true && date1 is null && date3 between testdate1 and testdate2 &&
string2 is null)

Jeff Butler


On Mon, Aug 11, 2008 at 11:23 PM, Ibatis534 <ib...@mailinator.com> wrote:

>
> I have question relating to using the Abator Example Class with Java 5.
>
> How would create the following query using a java5 example class:
>
> if (bool1 not true && date1 is null &
>    ((date2 between testdate1 and testdate2 and string1 is null)or (date3
> between testdate1 and testdate2 and string2 is null))
>
> My attempts aren't going so well.
>
> TIA
> --
> View this message in context:
> http://www.nabble.com/Complex-Abator-Query-tp18937755p18937755.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>