3 Replies Latest reply on Mar 27, 2008 6:38 AM by Manik Surtani

    How to prevent the frequently query execution

    Thiagu Mariappan Novice

      Hai every one
      I am new to Jboss Cache.
      I need to display the large amount of data in a dataTable.
      I need to prevent the frequently executed query.
      I need to display the page by using the cache data.
      I need the query execution at beginning when i visit the page or after the cache expire.
      i try to do with Page fragment caching. I found page data is in the cache but i can’t stop the query execution and still i am getting a poor load time.

      thia is xhtml code

      s:cache key="#{subcategoryName}" region="/Topic" enabled="true">
      <rich:dataTable value="#{productList}" var="Product">
      <f:facet name="header">
      <h:outputText value="SubcategoryName" />
      <h:outputText value="Product Name" />
      <h:outputText value="#{Product.subcat}" />
      <h:outputText value="#{Product.name}" />

      ad this my session bean code
      public class ProductsAction implements ProductsLocal,Serializable
      @Out(required=false,scope = CONVERSATION )
      String subcategoryName;
      List<TblProducts> productList;
      public String selectFromRequest() {
       productList =em.createQuery("select t from TblProducts t where t.subcat="+ subcategoryName).getResultList();

      i am not sure is there any logic need in my session bean side.
      i try pojoCache in my session bean side
      inject the org.jboss.cache.aop.PojoCache class in session bean side for implement the JBossCache.
      this is what i am try
       @In(create = true)
       PojoCache pojoCache;
       productList = (List<TblProducts>) pojoCache.get("productLiat", "hid");
       if (prodlis==null)
       productList =em.createQuery("select t from TblProducts t where t.subcat="+ subcategoryName).getResultList();
       pojoCache.put("productLiat", "subcategoryName", prodlis);
      } catch(CacheException e){

      but i have problem with pojoCache.get method , it gives null pointer exception.
      please any one suggest me how to stop frequently query execution .