4 Replies Latest reply on Nov 25, 2005 1:33 AM by icyjamie

    performance and caching in the hibernate mappings

    icyjamie

      Hello,

      I found out that setting caching on collection level improves performance a lot. Now it is set on class-level only. To check this:
      - adjust all definition mappings, so every collection includes a cache entry as well
      - write a test with a lot of process definition interaction (nodes, tasks, transitions, etc.)
      - write another test doing exactly the same
      - in every test, write out the hibernate second-level cache statistics at the end of the test (don't forget to activate them)
      You will see a lot of cache hits for the second test, and if you enabled hibernate to show the sql, it shows less calls in the second test.

        • 1. Re: performance and caching in the hibernate mappings
          camedinag

          Hello,

          Can you give an example of what must be changed in hibernate.cfg.xml for caching

          Thanks

          • 2. Re: performance and caching in the hibernate mappings
            icyjamie

            in hibernate.properties, I added:

            hibernate.cache.use_second_level_cache=true
            hibernate.cache.use_query_cache=true


            in every hbm file, look up collection definitions and add

            <cache usage="nonstrict-read-write"/>
            
            e.g.
            
             <list name="nodes" cascade="all">
             <cache usage="nonstrict-read-write"/>


            • 3. Re: performance and caching in the hibernate mappings
              stembol

              A few remarks:

              hibernate.cache.use_second_level_cache is is enabled by default for classes which specify a mapping.

              hibernate.cache.use_query_cache enables the query cache (individual queries still have to be set cachable). Do you use cachable queries?

              The nonstrict-read-write strategy you use is probably not the best one for every collection. The other strategies are: read only, read/write, and transactional.

              • 4. Re: performance and caching in the hibernate mappings
                icyjamie

                It was just a quick fix, just to see how things would improve. Of course, other settings must be examined. I guess use_query_cache is not needed, because from what I've seen from sourcecode, queries are not set to be cached (and maybe would be impractical in this situation).
                I've included the use_second_level_cache to turn it on and off, for testing purposes. So indeed, the default is "on".