3 Replies Latest reply on Mar 2, 2016 2:13 AM by Galder Zamarreño

    Infinispan 8 support for Hibernate 3.6 hibernate.cache.provider_class

    Colin Negrow Newbie

      I have below Hibernate 3.6 configuration and want to switch to Infinispan 8. Is it possible?

      Our solution is based on old JBoss cache 1.4 TreeCache. Infinispan was forked some time ago and today it also has TreeCache in its structure and documentation with suggestion to migrate from old TreeCache to new one.


      Tree API Module

      Infinispan’s tree API module offers clients the possibility of storing data using a tree-structure like API. This API is similar to the one provided by JBoss Cache, hence the tree module is perfect for those users wanting to migrate their applications from JBoss Cache to Infinispan, who want to limit changes their codebase as part of the migration. Besides, it’s important to understand that Infinispan provides this tree API much more efficiently than JBoss Cache did, so if you’re a user of the tree API in JBoss Cache, you should consider migrating to Infinispan.



      <prop key="hibernate.dialect">${db.dialect}</prop>

                          <prop key="hibernate.show_sql">${show.sql}</prop>

                          <prop key="hibernate.bytecode.use_reflection_optimizer">false</prop>

                          <prop key="hibernate.cache.provider_class">Custom org.jboss.hibernate.jbc.cacheprovider.TreeCacheProvider</prop>

                          <prop key="hibernate.cache.use_second_level_cache">FALSE</prop>

                          <prop key="hibernate.cache.use_query_cache">TRUE</prop>



      Here is old cache provider:



          public class CustomTreeCacheProvider extends TreeCacheProvider implements org.hibernate.cache.CacheProvider {


              private TreeCache cache;


              private TransactionManager transactionManager;


              private CacheProperties cacheProperties;


              public Cache buildCache(String regionName, Properties properties) throws CacheException {


                  return new JBCCache(cache, regionName, cacheProperties, transactionManager);




              public long nextTimestamp() {

                  return System.currentTimeMillis() / 100;



              public void start(Properties properties) throws CacheException {


                  try {

                      cache = new org.jboss.cache.TreeCache();

                      cacheProperties = new CacheProperties(properties);

                      PropertyConfigurator config = new PropertyConfigurator();


                      config.configure(cache, ""someXMLfile.xml"");


                      TransactionManagerLookup tml = TransactionManagerLookupFactory.getTransactionManagerLookup(properties);


                      if (tml!=null) {

                          cache.setTransactionManagerLookup( new TransactionManagerLookupAdaptor(tml, properties) );

                          transactionManager = tml.getTransactionManager(properties);





                  catch (Exception e) {

                      throw new CacheException(e);




              public void stop() {

                  if (cache!=null) {







              static final class TransactionManagerLookupAdaptor implements org.jboss.cache.TransactionManagerLookup {

                  private final TransactionManagerLookup tml;

                  private final Properties props;

                  TransactionManagerLookupAdaptor(TransactionManagerLookup tml, Properties props) {




                  public TransactionManager getTransactionManager() throws Exception {

                      return tml.getTransactionManager(props);