ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Heliodromel <samuel.maisonne...@gmail.com>
Subject Re: Sort resultset from multiple requests
Date Wed, 24 Sep 2008 07:51:05 GMT

Hi Kay,

Thanks for your answer.

Actually, the getCatName is just a example, it could be "select * from Cat"
and the table Cat would be constituted with 2 fields : a name and an age.

I had already tried to use the groupBy property but it didn't work. Actually
i was using it wrong. This morning, i tried an other time and it worked.
It's really easy to use but i don't know why i couldn't make it work...maybe
tired...;)

So here is the solution, applied to my example, for people who would have
the same problem :

For example if i want my result to be order by the name of the cats, i just
have to add a groupBy attribute in the resultMap to indicate iBatis how to
sort the result :

<resultMap id="MyRequest.result" groupBy="cat.name">
    <result property="firstname" column="firstname" columnIndex="1"/>
    <result property="lastname" column="lastname" columnIndex="2"/>
    <result property="age" column="age" columnIndex="3"/>
    <result property="cat" column="ref_cat" columnIndex="4"
select="getCatName"/>
</resultMap> 

Thanks again for your help,

Regards,

Helio.


Kai Grabfelder-2 wrote:
> 
> Hi Helio,
> 
> what does your getCatName select looks like? Can't you just use an order
> by in that select? Furthermore, you
> may want to have a look at the groupBy feature of iBATIS to avoid the n+1
> select problem.  The documentation
> [1] describes this in more detail.
> 
> Regards
> 
> Kai
> 
> [1]
> http://svn.apache.org/repos/asf/ibatis/trunk/java/ibatis-2/ibatis-2-docs/en/
> 
> 
-- 
View this message in context: http://www.nabble.com/Sort-resultset-from-multiple-requests-tp19627486p19643717.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Mime
View raw message