How to prevent the frequently query execution
thiagu.m Mar 20, 2008 11:48 AMHai 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"> <h:form> <rich:dataTable value="#{productList}" var="Product"> <f:facet name="header"> <rich:columnGroup> <h:column> <h:outputText value="SubcategoryName" /> </h:column> <h:column> <h:outputText value="Product Name" /> </h:column> </f:facet> </rich:columnGroup> <h:column> <h:outputText value="#{Product.subcat}" /> </h:column> <h:column> <h:outputText value="#{Product.name}" /> </h:column> </rich:dataTable> </h:form> </s:cache>
ad this my session bean code
@Stateful @Name("search") public class ProductsAction implements ProductsLocal,Serializable { @Out(required=false,scope = CONVERSATION ) @RequestParameter String subcategoryName; @Out(required=false) List<TblProducts> productList; @Begin(join=true) 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; try { 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){ e.printStackTrace(); }
but i have problem with pojoCache.get method , it gives null pointer exception.
please any one suggest me how to stop frequently query execution .
By
Thiagu.mr