1 Reply Latest reply on Aug 15, 2009 1:00 PM by swd847

    Populating two very similar dataTables with one query?

    asookazian

      So I have two rich:dataTables on the same JSF page that are based on Lists from result sets that have two different filters in the where clause.


      So the select clause and from clause may be identical.  I am wondering if I can avoid two db trips and somehow dynamically apply the filter after the List is populated by the result set from Hibernate.


      Is this possible to do?  What is the best way to handle this scenario?


      I'd rather not iterate thru the List and dynamically remove entities in the List.  That seems strange and never seen an example like that in the JPA/Hibernate books.


      So to be more specific, one dataTable needs widgets in a certain status and the other needs widgets in all the other statuses (so two non-overlapping data sets).

        • 1. Re: Populating two very similar dataTables with one query?
          swd847

          You have to either filter in the DB or iterate over the list.


          There is no real problem with iterating over the list, java scales better than the database.


          Rather than removing entities you are probably better off constructing two new lists, if you order it by status you can probably get away with only iterating half way through the list and then using .sublist().