ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ron Grabowski <rongrabow...@yahoo.com>
Subject Re: Dynamic condition/fields
Date Tue, 20 Sep 2005 15:19:48 GMT
Q1. 
You could pass your parameters in as a Map and use a literal:

 <isNotNull prepend="and" property="attribute1">
  FIELD1 $likeClause$ #attribute1#
 </isNotNull>

Q2.
You could use a literal for this as well. Remember that ibatis isn't a
sql parser, it doesn't know anything about your column names. It sees
everything as text so there's nothing like this:

 // FAKE SYNTAX, DOES NOT EXIST
 Statement statement = 
  sqlMapper.getStatement("GetOne").addColumn("DateAdded");
 List list = statement.select();

Q3.
All sql statements to/from the database are logged. You can capture
those and do whatever you want with them.

--- Mathew Samuel <grandarchville@yahoo.com> wrote:

> 
> Q1. What's the best way to dynamically alter ('=' or
> 'like') to ('!=' or 'not like') in a pre-constructed
> option ? e.g.
> 
>   <isNotNull prepend="and" property="attribute1">
>     FIELD1 like #attribute1#
>   </isNotNull>
> 
> can become
> 
>   <isNotNull prepend="and" property="attribute1">
>     FIELD1 not like #attribute1#
>   </isNotNull>
> 
> or vice-versa.
> 
> 
> 
> Q2. Is there a way to dynamically add fields to an SQL
> statement (select/update/insert/delete) ? e.g. A UI
> customization that indirectly allows adding a field to
> an existing table, could then have statements that
> operate on those new fields.
> 
> 
> 
> Q3. Does Ibatis allow an API call to retrieve the
> constructed SQL right before the execution ? (Perhaps
> for achieving the problem above)
> 
> 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> 


Mime
View raw message