cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "true");
cfg.setProperty(Environment.USE_QUERY_CACHE, "true");
cfg.setProperty(Environment.CACHE_REGION_FACTORY, "org.hibernate.cache.infinispan.InfinispanRegionFactory");
Properties envProps = Environment.getProperties();
envProps.put(AvailableSettings.JTA_PLATFORM, new JBossStandAloneJtaPlatform());
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry(envProps);
String[] mappings = new String[]{"org/hibernate/test/cache/infinispan/functional/Item.hbm.xml"};
for (String mapping : mappings) {
cfg.addResource(mapping, Thread.currentThread().getContextClassLoader());