There's nothing in iBATIS that will do this. I've done something similar in the past by adding a getter to the parameter object and coding the logic in the getter method. Like this:
public boolean isComplexCondition {
...some complex decision
}
Then coding an <isEqual property="complexCondition" value="true"> in the SQL Map.
I ended up liking this better anyway - I think the logic is easier to understand when written in Java.
Jeff Butler
On 6/28/06, Vadim Grinshpun <[EMAIL PROTECTED]> wrote:
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: [EMAIL PROTECTED]]
> Sent: woensdag 28 juni 2006 20:58
> To: [email protected]
> 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
>
>
