Results 1 to 2 of 2

Thread: jdbctemplate.query() - sorted result set

Hybrid View

  1. #1
    Join Date
    Oct 2009
    Posts
    5

    Unhappy jdbctemplate.query() - sorted result set

    Hi Folks,

    I have a query like this :

    query = select * from TABLE where <condition> order by <column> desc;

    My jdbctemplate method does the following.
    It does return a list of object, but these are not sorted according to my query.

    List result = this.getJdbcTemplate().query(
    query, new Object[]{..},
    new RowMapper() {
    public Object mapRow(ResultSet rs, int rowNum)
    throws SQLException {
    SomeDTO someDTO = new SomeDTO();
    someDTO.setxxx(rs
    .getString("SOMEFIELD"));
    someDTO.setyyy(rs.getInt("SOMEFIELD2"));

    return someDTO;
    }
    });

    What Collection object does the query() method return?
    I am not sure if there is anything else to be done.

    Any pointers ? pls help.

    Thanks

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    Please use [ code][/code ] tags when posting code !!!

    Well it returns an ArrayList (check the source code and you will see) it basically adds the rows as returned from the ResultSet so if there is something odd either your query is returning the results in a different order or there is some munging going on on the List which interferes/changes the ordering.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •