List of usage examples for org.hibernate.cfg AvailableSettings QUERY_CACHE_FACTORY
String QUERY_CACHE_FACTORY
To view the source code for org.hibernate.cfg AvailableSettings QUERY_CACHE_FACTORY.
Click Source Link
From source file:com.corundumstudio.core.extensions.hibernate.BaseTest.java
License:Apache License
protected static void initHibernate() { Properties props = buildDatabaseConfiguration("db1"); Configuration cfg = new Configuration(); cfg.setProperty(Environment.GENERATE_STATISTICS, "true"); cfg.setProperty(AvailableSettings.HBM2DDL_AUTO, "create"); cfg.setProperty(AvailableSettings.CACHE_REGION_FACTORY, InfinispanRegionFactory.class.getName()); cfg.setProperty(InfinispanRegionFactory.INFINISPAN_CONFIG_RESOURCE_PROP, "infinispan.xml"); cfg.setProperty(AvailableSettings.QUERY_CACHE_FACTORY, DynamicQueryCacheFactory.class.getName()); cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "true"); cfg.setProperty(Environment.USE_QUERY_CACHE, "true"); cfg.addAnnotatedClass(SimpleEntity.class); cfg.buildMappings();/*from w w w .j av a 2 s.c om*/ ServiceRegistryBuilder sb = new ServiceRegistryBuilder(); ServiceRegistry serviceRegistry = sb.applySettings(props).buildServiceRegistry(); sessionFactory = (SessionFactoryImplementor) cfg.buildSessionFactory(serviceRegistry); EventListenerRegistry registry = sessionFactory.getServiceRegistry() .getService(EventListenerRegistry.class); registry.getEventListenerGroup(EventType.POST_UPDATE).appendListener(queryCacheEntityListener); registry.getEventListenerGroup(EventType.POST_INSERT).appendListener(queryCacheEntityListener); registry.getEventListenerGroup(EventType.POST_DELETE).appendListener(queryCacheEntityListener); }