ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Butler" <jeffgbut...@gmail.com>
Subject Re: abator: dynamic order by
Date Fri, 11 Aug 2006 14:30:19 GMT
With Abator generated methods you could use the selectByExample method,
passing in an empty example parameter, to do the select all.  Then you can
also pass the order by clause.  Like this:

OdmCustomerExample example = new OdmCustomerExample();
List answer = dao.selectByExample(example, "FIRST_NAME asc, LAST_NAME
desc");

Jeff Butler


On 8/11/06, Thomas Karl Schwaerzler <Thomas.Schwaerzler@uibk.ac.at> wrote:
>
>
>
> hello,
>
> i'm looking for something that allows me to use a dynamic order by value
> in abator.
> the method could look something like this:
>
> List<Customer> getCustomersOrdered(Long groupId, String orderColumn,
> String ascDesc)
>
>
> ..where orderColumn is a column name and ascDesc is either 'ASC' or 'DESC'
>
> in this mailinglist i found someone seemingly looking for something
> similar just using ibatis:
>
> http://www.mail-archive.com/user-java@ibatis.apache.org/msg05010.html
>
>
> You can add this to your select statement:
>
>     <isNotEmpty property="orderByColumn">
>       order by $orderByColumn$
>     </isNotEmpty>
>
> Then add a getOrderByColumn() method to your parameter object.
>
> Jeff Butler
>
>
> this works, i just had to add an extra class only containing orderByColumn
> + getter ...
>
>
> my 1. attempt was something like this:
>
> <select id="getCustomersOrdered" parameterClass="java.lang.String"
> resultMap="abatorgenerated_OdmCustomerResult">
>     select ID,
>       TITLE,
>       FIRST_NAME,
>       LAST_NAME,
>       STREET,
>       ZIP_CODE,
>       CITY,
>       COUNTRY,
>       PHONE_MOBILE,
>       PHONE,
>       FAX,
>       EMAIL,
>       GROUP_ID
>     from c108272dev.ODM_CUSTOMER
>     order by #value#
> </select>
>
>
> where the parameter contained e.g. "FIRST_NAME ASC"
>
> but this did not deliver the expected result.
>
>
> my question is:
>
> is there a more comfortable way to to something like this with abator?
>
>
> thnx in advance
> tom :)
>

Mime
View raw message