1 Reply Latest reply on Feb 14, 2009 10:19 PM by Brian Stansberry

    <cache-configs/> or <jbosscache> format?

    nikita tovstoles Newbie

      I am trying to configure JBossCache 3 as 2nd level cache for Hibernate 3.3.1.GA.

      Official-looking http://galder.zamarreno.com/wp-content/uploads/2008/09/hibernate-jbosscache-guide.pdf says caches ought to be configured like so (see p.24):

      <?xml version="1.0" encoding="UTF-8"?>
      <!-- A config appropriate for entity/collection caching. -->
      <cache-config name="optimistic-entity">

      On the other hand, http://www.jboss.org/file-access/default/members/jbosscache/freezone/docs/3.0.2.GA/userguide_en/pdf/userguide_en.pdf instructs this format (p.105):

      <?xml version="1.0" encoding="UTF-8"?>
      <jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"


      Is the latter the correct one? If so, then I am guessing the earlier format was used with JBC2 and was deprecated in JBC 3?

      If that's the case then should I be using RegionFactory/CacheProvider *other* than one supplied with Hibernate 3.3.1.GA - org.hibernate.cache.jdbc2.JBossCacheRegionFactory? This RegionFactory expects cache config in <cache-config/> format.

        • 1. Re: <cache-configs/> or <jbosscache> format?
          Brian Stansberry Master

          Yes, the early format was deprecated in JBC 3, although it should still work fine.

          The schema shown on p 105 of the 3.0.2.GA userguide is for a single config, while the old "cache-configs" format was used when you wanted to specify several named configs in a single document, which is what org.hibernate.cache.jbc2.JBossCacheRegionFactory expects. But, JBC3 has a new schema to handle that too, although I'm not sure if it's covered in the docs. Here's an example:

          <?xml version="1.0" encoding="UTF-8"?>
          <registry:cache-configs xmlns="urn:jboss:jbosscache-core:config:3.0" xmlns:registry="urn:jboss:jbosscache-core:cache-repo:3.0">
           Various JBoss Cache configurations, suitable for different caching
           uses (e.g. entities vs. queries).
           In all cases, TransactionManager configuration not required.
           Hibernate will plug in its own transaction manager integration.
           <!-- A config appropriate for entity/collection caching. -->
           <registry:cache-config name="optimistic-entity">
           <locking lockAcquisitionTimeout="15000" nodeLockingScheme="optimistic"/>
           <!-- A config appropriate for entity/collection caching that
           uses pessimistic locking -->
           <registry:cache-config name="pessimistic-entity">
           <locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000" nodeLockingScheme="pessimistic"/>

          The content of a "registry:cache-config" element is the same as the content of a "jbosscache" element shown in the user guide. Only difference is the "registry:cache-config" element must have a "name" attribute where you give a name to the config, same as the JBC 2 "cache-config" element's "name" attribute.

          If you are using JBC3, I'm quite certain JBossCacheRegionFactory will handle the JBC3 schema without problems, since it delegates the parsing to JBC3 code.