ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gentile, Wayne \(Hitachi Consulting\)" <wayne.gentile-...@eds.com>
Subject RE: dynamic order by clause
Date Mon, 21 Aug 2006 14:01:34 GMT
You have a couple of options.

 

1.	Pass a map as the parameterClass and add your User object,
SortField, and SortType to the map before calling the statement. The key
names of the map will match the names in the map.
2.	Create a SortCriterion class with a SortField and SortType
property and pass multiple instances using a map (if you want to sort by
multiple fields).

 

The map then looks like this:

 

<select id="SelectUser" parameterClass="map" resultMap="UserResult"> 
    ... 
    <dynamic prepend="ORDER BY "> 
        <isNotEmpty property="SortField"> 
            ORDER BY $SortField$ $SortType$ 
        </isNotEmpty> 
    </dynamic> 
</select>

 

________________________________

From: Stief Dirckx [mailto:Stief.Dirckx@icasa-consulting.com] 
Sent: Monday, August 21, 2006 1:45 AM
To: user-cs@ibatis.apache.org
Subject: dynamic order by clause

 


Hi 

I'm having some questions about the dynamic sorting example in the
iBatis datamapper manual on page 51. What I want to do is is to pass an
object to an select statement but I also want to make the sorting
dynamic (sort field and sort type). But how can I pass these 2 extra
parameters using the QueryForList method? 

This is what I have up to now: 
<select id="SelectUser" parameterClass="User" resultMap="UserResult"> 
    ... 
    <dynamic prepend="ORDER BY "> 
        <isNotEmpty property="SortField"> 
            ORDER BY $SortField$ $SortType$ 
        </isNotEmpty> 
    </dynamic> 
</select> 
But with this solution I have to add 2 properties to my user class
(sortfield and sorttype). How can I avoid doing that? 

Stief. 


Mime
View raw message