1 Reply Latest reply on May 2, 2007 11:09 PM by Ricardo Memoria

    entity-query.resultCount strange behaviour

    Ricardo Memoria Novice

      I have a table (Product) with 7000 records and I've configured an entity-query like that:

      <framework:entity-query name="products" ejbql="from Product p" max-results="20" order="p.name">
       <framework:restrictions>
       <value>lower(p.name) like lower(#{productHome.productName} + '%')</value>
       </framework:restrictions>
      </framework:entity-query>


      In my page I have a resume of the result search (record index and number of records found), pagination control like that in SEAM doc (section 10.3) and an inputText to enter part of the product name like that:


      <rich:panel>
      <f:facet name="header">Filtros</f:facet>
      <b>Product name: </b>
      <h:inputText value="#{productHome.productName}" style=" width : 227px;"/>
      <h:commandButton value="Search" />
      </rich:panel>
      
      <p/>
      Results: <b>#{products.firstResult + 1} -
       #{products.firstResult+20 > products.resultCount ? products.resultCount : products.firstResult+20}
       </b> of <b>#{products.resultCount}</b><p/>
      
      <s:link rendered="#{products.previousExists}" value="First page" style="margin-right:20px" >
       <f:param name="firstResult" value="0" />
       <f:param name="name" value="#{productHome.productName}" />
      </s:link>
      
      <s:link rendered="#{products.previousExists}" value="Previous page" style="margin-right:20px" >
       <f:param name="firstResult" value="#{products.previousFirstResult}" />
       <f:param name="name" value="#{Home.productName}" />
      </s:link>
      
      <s:link view="/admin/products.xhtml" rendered="#{products.nextExists}" value="Próxima página" style="margin-right:20px" >
       <f:param name="firstResult" value="#{products.nextFirstResult}" />
       <f:param name="name" value="#{productHome.productName}" />
      </s:link>
      
      <s:link view="/admin/products.xhtml" rendered="#{products.nextExists}" value="Última página" >
       <f:param name="firstResult" value="#{products.lastFirstResult}" />
       <f:param name="name" value="#{productHome.productName}" />
      </s:link>


      and the rest of the page is a dataTable that is working perfectly.
      The code in bold shows a resume like in google:
      Result: 1-20 of 7500 (for example)

      In pages.xml I have:

      <page view-id="/admin/products.xhtml">
       <param name="firstResult" value="#{products.firstResult}" />
       <param name="name" value="#{productHome.productName}" />
       <navigation from-action="#{productHome.remove}">
       <redirect view-id="/admin/products.xhtml"></redirect>
       </navigation>
      </page>


      If I inform part of a product name, the datatable shows the products filtered correctly, but the property products.resultCount returns the total number of records (without filtering)

      Detail: If I filter again (the same filter) or move to the next page using the navigation controls, the resultCount returns the right number (filtered).

      I don't know if I made something wrong or it's a bug.

      Any sugestion or workaround to this problem.

      Thanks,
      Ricardo Memória