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: Wrong sorting when using orderBy clause
Date Mon, 15 Dec 2008 18:07:58 GMT
If you turn on logging, then you can verify exactly what's coming back
from the DB.

My guess is that something's not quite right in your Service class.
groupBy works best when there is a very simple getter/setter for the
list.  For example, in your Service class you should have something
like this:

public class Service {
  private List<Tag> tagList;
  // other properties

  public List<Tag> getTagList() {
    return tagList;
  }

  public void setTagList(List<Tag> tagList) {
    this.tagList = tagList;
  }
}

You don't need any more logic with the tagList property.  Most of the
issues we see with groupBy are related to users trying to do something
more complex with the List properties.

Jeff Butler


On Mon, Dec 15, 2008 at 11:55 AM, Corrado Alesso
<co.alesso@fastwebnet.it> wrote:
> Thanks for your reply.
>
> Yes, the query has an 'order by' on just those two columns.
>
> ORDER BY t1.id ASC, t2.tag ASC
>
>
> I can provide some more information to track down the problem...
>
> The query has a LIKE clause defined as
>
> WHERE LOWER(tag) LIKE LOWER('%$value$%')
>
>
> With pgAdmin I always get the correct results, no matter what I pass to the
> LIKE clause.
> Instead, when I refresh my page that fetches the data with iBatis, I get
> different results if I pass "grap", "graph", or "graphic" (I mean, different
> ordering in the 'tagList' property).
>
>
> Between the DB and iBatis there is Spring and the JDBC driver
> (postgresql-8.3-603.jdbc4.jar).
>
> I can provide a test program that reproduce this behaviour.
>
> If iBatis use, as expected, the order returned by the DB, maybe there's an
> issue in the driver?
>
> Please help me track down this problem :(
>
>
> Thank you,
> Corrado
>
>
> In data 15 dicembre 2008 alle ore 18:21:47, Jeff Butler
> <jeffgbutler@gmail.com> ha scritto:
>
>> No - I have tests running that show this is not an issue.
>>
>> iBATIS will use the order returned from the database.  Make sure your
>> SQL has an order by clause containing both id and tag.
>>
>> Jeff Butler
>>
>>
>> On Mon, Dec 15, 2008 at 11:03 AM, Corrado Alesso
>> <co.alesso@fastwebnet.it> wrote:
>>>
>>> In data 14 dicembre 2008 alle ore 15:33:40, Corrado Alesso
>>> <co.alesso@fastwebnet.it> ha scritto:
>>>
>>>> Hello everyone, I'm facing a problem with iBatis.
>>>
>>> [cut]
>>>
>>> Do you think that this should be filed as an iBatis issue?
>>>
>
>
>

Mime
View raw message