Discussions

General J2EE: apply filter and sort to result

  1. apply filter and sort to result (5 messages)

    I need to display the result of a select from database like a report on web page. also I have to apply functionality such as filter and sorting.
    what is the best way to do this?
    do I have to reconstruct the select sql statement everytime and do retireveing from database everytime.
    in MS ADO,there is filter and sort in recordset,what about in JAVA world?

    Threaded Messages (5)

  2. apply filter and sort to result[ Go to top ]

    It would be better to modify the SQL and let the DB server do the job for you. If you are using Hibernate, there are sort and filter methods that can be applied directly to the query object. Otherwise, I would look at the jakarta Commons CollectionUtils package for sorting the results.
  3. apply filter and sort to result[ Go to top ]

    what I like is get the result from database and cache the result as an object,then I can munipulate the result such as filtering and sorting.
    any idea?
  4. apply filter and sort to result[ Go to top ]

    I think it depends on, how much and how long data to be cached. If you application use small amount of data for a short period, then you can cache for filtering and sorting.
    Otherwise you should do sorting and filter at database.
  5. apply filter and sort to result[ Go to top ]

    Thanks,
    How can I do for small amount and short period?
    why it's not apply for big?
  6. apply filter and sort to result[ Go to top ]

    Look at using EM Cache.

    You don't want to do it on large amounts of data because you'll be eating up memory very quickly, also the sorting and filtering operations will become expensive.