ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niels Beekman" <n.beek...@wis.nl>
Subject RE: flexible queries?
Date Wed, 28 Jun 2006 20:30:02 GMT
Sorry, I should have looked at it more closely. You are right, there is
currently no (at least easy) way to wire several conditions together
using AND or OR. So the constraints can be created, the union cannot.
There has been some discussion about replacing/enhancing the dynamic
SQL, but I do not know when this will be implemented, maybe one of the
developers can comment on this.

See:

http://opensource.atlassian.com/confluence/oss/display/IBATIS/Improved+D
ynamic+SQL+Whiteboard

Niels

-----Original Message-----
From: Vadim Grinshpun [mailto:vadim@ll.mit.edu] 
Sent: woensdag 28 juni 2006 22:22
To: user-java@ibatis.apache.org
Subject: Re: flexible queries?

Er... Thanks, but either you misread my example, or I completely do not 
understand what you mean.
The example I gave uses a large chunk of  iBATIS-like *pseudocode* 
(there is no 'if' tag and no 'or' tag!), and thus cannot work as is.
I've looked through the Dev Guide ( version that was in SVN as of 6/20),

but so far was unable to find anything that would allow for this kind of

functionality. (effectively, what I want is to have a *SINGLE* iBATIS 
conditional that would test multiple properties and OR the results).
Could you take another look at it, please, or explain in more detail?  
Thanks!
-Vadim
Niels Beekman wrote:
> Yes, that should work out just fine. See the Developer Guide for some
> examples...
>
> -----Original Message-----
> From: Vadim Grinshpun [mailto:vadim@ll.mit.edu] 
> Sent: woensdag 28 juni 2006 20:58
> To: user-java@ibatis.apache.org
> Subject: flexible queries?
>
> Hi everyone,
>
> Suppose I have a query where I want a join to be performed only if
*one 
> or more* of a set of parameters are present.
> Is there a way in SqlMaps to do something like this? (below is an 
> example snippet of  what I'd like to do, using some pseudocode in the 
> first <dynamic> section):
>
> SELECT * FROM
>     table_foo f, table_bar b
>    <dynamic> <!-- if any of the params in the conditional are defined,

> add one more table to join -->
>       <if>
>         <or>
>           <isEqual property="X.defined" compareValue="true" />
>           <isEqual property="X.defined" compareValue="true" />
>         </or>
>        <then>, table_baz z</then>
>       </if>
>    </dynamic>
>    WHERE f.field = b.field
>    <dynamic>
>      <isEqual property="X.defined" compareValue="true" prepend="AND" 
>  >z.x_field > #X.value#</isEqual>
>      <isEqual property="Y.defined" compareValue="true" prepend="AND" 
>  >z.y_field = #Y.value#</isEqual>
>   </dynamic>
>   
>
> Thanks,
> --Vadim
>
>   


Mime
View raw message