ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yee, Richard K CTR DMDC" <Richard.Yee....@osd.pentagon.mil>
Subject RE: flexible queries?
Date Wed, 28 Jun 2006 20:38:03 GMT
You should do this inside a stored procedure instead of using iBATIS or your
code to do it.


-----Original Message-----
From: Vadim Grinshpun [mailto:vadim@ll.mit.edu] 
Sent: Wednesday, June 28, 2006 11:58 AM
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):

    table_foo f, table_bar b
   <dynamic> <!-- if any of the params in the conditional are defined, 
add one more table to join -->
          <isEqual property="X.defined" compareValue="true" >
          <isEqual property="X.defined" compareValue="true"  >
       <then>, table_baz z</then>
   WHERE f.field = b.field
     <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>


View raw message