0 Replies Latest reply on Jun 26, 2008 11:17 AM by Dave Salmon

    read-ahead cache invalidate before any data access

    Dave Salmon Newbie


      I am trying to implement a read-ahead on-find strategy for a CMP bean using jboss 4.0.2.

      The finder method appears to cache all the required data and return a collection of local objects with cached data as evidenced by log output like

      2008-06-26 07:13:43,875 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCEJBQLQuery.StockData#findByPing] Executing SQL: SELECT DISTINCT t0_o.id, t0_o.ticker, t0_o.name, t0_o.currency, t0_o.quote, t0_o.open, t0_o.high, t0_o.low, t0_o.delta, t0_o.volume, t0_o.marketcap, t0_o.range, t0_o.divdate, t0_o.divyield, t0_o.exchange, t0_o.divrate, t0_o.pubdate, t0_o.provider, t0_o.updated FROM stockdata t0_o LEFT OUTER JOIN stockping t1_o_ping ON t0_o.id=t1_o_ping.id WHERE t1_o_ping.ping > ? AND t0_o.quote IS NOT NULL
      2008-06-26 07:13:43,875 TRACE [org.jboss.ejb.plugins.cmp.jdbc.JDBCEJBQLQuery.StockData#findByPing] param: i=1, type=INTEGER, value=20240053
      2008-06-26 07:13:43,875 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.StockData#id] result: i=1, type=java.lang.Integer, value=36
      2008-06-26 07:13:43,875 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.StockData#ticker] result: i=2, type=java.lang.String, value=USTYN
      2008-06-26 07:13:43,875 TRACE [org.jboss.ejb.plugins.cmp.jdbc.ReadAheadCache.StockData] Add preload data: entity=StockData pk=36 field=ticker

      However, when I call the value method for each of the local objects in the collection I get:

      2008-06-26 08:02:00,437 TRACE [org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.StockData] RESET PERSISTENCE CONTEXT: id=36
      2008-06-26 08:02:00,437 TRACE [org.jboss.ejb.plugins.cmp.jdbc.ReadAheadCache.StockData] load data: entity=StockData pk=36
      2008-06-26 08:02:00,437 TRACE [org.jboss.ejb.plugins.cmp.jdbc.ReadAheadCache.StockData] No preload data found: entity=StockData pk=36
      2008-06-26 08:02:00,437 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCEntityBridge.StockData] Default eager-load for entity: readahead=null
      2008-06-26 08:02:00,437 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.StockData] Executing SQL: SELECT ticker, name, currency, quote, open, high, low, delta, volume, marketcap, range, divdate, divyield, exchange, divrate, pubdate, provider, updated FROM stockdata WHERE (id=?)
      2008-06-26 08:02:00,437 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.StockData#id] param: i=1, type=INTEGER, value=36

      This indicates to me that all the cached data is tossed out and reloaded.

      The method invoked is running as a transaction and consists essentially of

      Collection coll = StockDataUtil.getLocalHome().findByPing(currMinutes);
      for (Iterator i = coll.iterator(); i.hasNext(); )
      StockDataLocal sdl = (StockDataLocal)i.next();
      StockUpdateValue val = sdl.getUpdateValue();

      Any help would be appreciated.

      Dave Salmon
      FreeRange Communications, Inc