ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kris Barnhoorn" <k...@biassweb.be>
Subject sql fragment as parameter
Date Thu, 30 Dec 2004 16:54:23 GMT
Hi,
 
First I'd like to thank the developers for this great tool.
 
I'd like to insert an sql fragment as a parameter to an sql select
statement.
what i do is generate some sql in a class which is used as
parameterClass in the xml file
 
the whereCriteriaString constructs the string based criteria selectable
on the webpage. Users can choose the make more than one "filter"
 
filter:  property | value | (AND | OR)
add filter
 
 
So I simply did this:
 
      <select id="getPojos" parameterClass="org.foo.SqlQuery"
            resultClass="org.foo.Pojo">
            SELECT *
            FROM `pojos` 
            WHERE 
            <dynamic>
                  <isNotEmpty property="whereCriteriaString">
                        #whereCriteriaString#
                  </isNotEmpty>
            </dynamic>
      </select>
 
What generates 
218 [main] DEBUG sql.PreparedStatement  - {pstm-100004}
PreparedStatement: SELECT * FROM `pojos` WHERE ? 
218 [main] DEBUG sql.PreparedStatement  - {pstm-100004}
PreparedStatement: Parameters: [(ld.language  =  'en' ) ]
218 [main] DEBUG sql.PreparedStatement  - {pstm-100004} Types:
[java.lang.String]
 
This doesn't work
 
So my question is can iBatis generate this?
 
218 [main] DEBUG sql.PreparedStatement  - {pstm-100004}
PreparedStatement: SELECT * FROM `pojos` WHERE (ld.language  =  'en' )  
 
 
I looked at <iterate>, but I don't think I can emulate a similar
behaviour with it.
 
 
Thank you,
 
Kris.
 
 

Mime
View raw message