2 Replies Latest reply on Jul 4, 2012 8:15 AM by ctomc

    Hibernate 4.0.1 second level cache not enabled

    ohmygod

      I am using Hibernate 4.0.1 with JBoss 7.1.1. Now I am getting this error about the second-level cache.

       

      19:05:34,914 ERROR [com.demo.util.testMDB] (Thread-3 (HornetQ-client-global-threads-1905728914))  org.hibernate.cache.NoCachingEnabledException: Second-level cache is not enabled for usage [hibernate.cache.use_second_level_cache | hibernate.cache.use_query_cache]
      

       

      I have added

       

       

      hibernate.cache.provider_class org.hibernate.cache.HashtableCacheProvider
      
      

       

      in hibernate.cfg.cml and

       

       

      ## disable the second-level cache
      
      
      #hibernate.cache.use_second_level_cache false
      
      

       

      should mean the second-level cache is enabled by default. I also changed it to

       

      hibernate.cache.use_second_level_cache true
      

       

      and add

       

      hibernate.cache.use_query_cache true
      

       

      but still got no luck.

       

       

      Any hint where I got it wrong?

        • 1. Re: Hibernate 4.0.1 second level cache not enabled
          ohmygod

          More information to this problem. The exception is thrown when using JBPM's hibernate configuration file (I call it hibernate-jbpm.cfg.xml) where there is no cache configuration. But when I added

           

          <property name="hibernate.cache.use_second_level_cache">true</property>
          <property name="hibernate.cache.use_query_cache">true</property>
          
          

          it is still not working.

           

          Any thoughts?

          • 2. Re: Hibernate 4.0.1 second level cache not enabled
            ctomc

            Hi,

             

            hibernate 4 is JPA2 implementation, and since JPA2 has now standardized how caching works you need to pass him standard configuration options.

            take a look at documentation to find out what exacly are they

             

             

            --

            tomaz