1 Reply Latest reply on Dec 4, 2008 3:54 AM by apdo

    query cache configuration

    apdo Newbie

      I am using jboss 4.2.3 GA

      I want to use EJB3 with caching. I don't plan in the short term to use clustering. Is Jboss cache the most common caching mechanism to be use for EJB3 on Jboss?

      To enable caching on the default configuration, I follow the french instruction provided in at the following location:
      http://wiki.objetdirect.com/wiki/index.php?title=Cache_2nd_niveau_Hibernate

      It says to copy the following file from the all configuration to the default configuration:
      jboss-cache*.jar
      jgroup*.jar (most probably useless in my case since I doesn't use clustoring.)
      ejb-entity-cache-service.xml

      I have confured ejb-entity-cache-service.xml with LOCAL since I am not using clustering.

      My persistence.xml file look like this:

      <persistence>
       <persistence-unit name="securityEJB3">
       <jta-data-source>java:/securityEJB3DS</jta-data-source>
       <properties >
       <property name="hibernate.hbm2ddl.auto" value="update"/>
       <property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/>
       <property name="hibernate.show_sql" value="true"/>
       <property name="hibernate.cache.use_query_cache" value="true"/>
       <property name="hibernate.cache.provider_class" value="org.jboss.ejb3.entity.TreeCacheProviderHook" />
       <property name="hibernate.treecache.mbean.object_name" value="jboss.cache:service=EJB3EntityTreeCache" />
       </properties >
       </persistence-unit>
      </persistence>
      


      According to my test, caching is working well if I find object using the entitymanager .find method and when I find entity children of another entity. I conclude that it is working find since after activating the second level caching I see Hibernate query in my server.log only for the first time I get an entity. The following call to entitymanager.find for the same entity doesn't generate hibernate query in my log.

      However, I think that my configuration didn't enable the query cache since for every execution of the same query using entitymanager.createQuery
      I see the hibernate query in my server.log file.

      Could you please tell me what is missing in my configuration to make the query cache working?

      Thank you,

      An Phong Do