[jboss-user] [JBoss Cache: Core Edition] - JPA entity caching with JBossCache in JBoss-5.0 GA

jaikiran do-not-reply at jboss.com
Mon Dec 29 06:51:43 EST 2008

I'm trying to move a EJB3 JPA example which has second level cache enabled to JBossAS-5.0 GA. I am following this wiki for instructions http://www.jboss.org/community/docs/DOC-13200. Based on those instructions i have been able to get the example deploying successfully in JBoss-5 GA. I have a couple of related questions:

1) Is there a way to access this second level cache from within the application (ex: from a EJB3 bean). I see that the java:CacheManager is registered in the JNDI. So would the following be the correct thing to do:

  | private Cache getCache() throws Exception
  |    {
  |       org.jboss.cache.CacheManager cacheManager = (CacheManager) new InitialContext().lookup("java:CacheManager");
  |       return cacheManager.getCache("mvcc-entity", false);
  |    }

The org.jboss.cache.CacheManager.getCache() accepts 2 arguments. I could not find the javadocs and wasn't sure what to pass. Based on some explanation from the wiki, i decided to pass mvcc-entity as the first param. What exactly are these parameters used for?

2) Once i get hold of the cache, is there some way through which i can figure out whether a particular entity is cached?

public boolean isCustomerInCache(Long id){
  |  Cache cache = getCache();
  |  // is there some way through which i can check if the entity is cached?
  | }

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4198722#4198722

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4198722

More information about the jboss-user mailing list