0 Replies Latest reply on Feb 3, 2004 11:51 PM by Kunal H. Parikh

    How to cache the results of a findByPrimaryKey()

    Kunal H. Parikh Newbie

      Hi All!

      I am attempting to chache the results returned by my CMP2.x EntityBean from the findByPrimaryKey() method.

      My jboss.xml file contains the following:

      <configuration-name>Standard CMP 2.x EntityBean with cache invalidation</configuration-name>


      However, the debug info shows something like EACH TIME that I call the EJB's LocalHomeInterface.findByPrimaryKey(138):
      2004-02-04 16:20:24,177 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCFindByPrimaryKeyQuery.CarsalesVehiclesMV#findByPrimaryKey] Executing SQL: SELECT vehicle_id FROM EJBTEST WHERE vehicle_id=?
      2004-02-04 16:20:24,178 TRACE [org.jboss.ejb.plugins.cmp.jdbc.JDBCFindByPrimaryKeyQuery.CarsalesVehiclesMV#findByPrimaryKey] Set parameter: index=1, jdbcType=INTEGER, value=138
      2004-02-04 16:20:24,182 TRACE [org.jboss.ejb.plugins.EntityInstancePool] 0/100 Free instance:org.jboss.ejb.plugins.EntityInstancePool@d0a6a3#null#null#false#class au.com.carsales.csBeans.entity.CarsalesVehiclesMVBean
      2004-02-04 16:20:24,182 TRACE [org.jboss.ejb.plugins.LogInterceptor] End method=findByPrimaryKey
      2004-02-04 16:20:24,182 TRACE [org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor] invokerBInding is null in ProxyFactoryFinder
      2004-02-04 16:20:24,182 TRACE [org.jboss.ejb.plugins.LogInterceptor] Start method=findByPrimaryKey
      2004-02-04 16:20:24,182 TRACE [org.jboss.ejb.plugins.TxInterceptorCMT] Current transaction in MI is null
      2004-02-04 16:20:24,182 TRACE [org.jboss.ejb.plugins.TxInterceptorCMT] TX_NOT_SUPPORTED for findByPrimaryKey
      2004-02-04 16:20:24,182 TRACE [org.jboss.ejb.plugins.TxInterceptorCMT] Thread came in with tx null
      2004-02-04 16:20:24,182 TRACE [org.jboss.ejb.plugins.EntityInstancePool] Get instance org.jboss.ejb.plugins.EntityInstancePool@d0a6a3#1#class au.com.carsales.csBeans.entity.CarsalesVehiclesMVBean
      2004-02-04 16:20:24,183 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCFindByPrimaryKeyQuery.CarsalesVehiclesMV#findByPrimaryKey] Executing SQL: SELECT vehicle_id FROM EJBTEST WHERE vehicle_id=?
      2004-02-04 16:20:24,183 TRACE [org.jboss.ejb.plugins.cmp.jdbc.JDBCFindByPrimaryKeyQuery.CarsalesVehiclesMV#findByPrimaryKey] Set parameter: index=1, jdbcType=INTEGER, value=138
      2004-02-04 16:20:24,187 TRACE [org.jboss.ejb.plugins.EntityInstancePool] 0/100 Free instance:org.jboss.ejb.plugins.EntityInstancePool@d0a6a3#null#null#false#class au.com.carsales.csBeans.entity.CarsalesVehiclesMVBean
      2004-02-04 16:20:24,187 TRACE [org.jboss.ejb.plugins.LogInterceptor] End method=findByPrimaryKey


      Effectively, my EJB hits the DB each time the findByPrimaryKey method is called and does not cache the results.

      What addidtional settings do I require to enable EJB caching ?