List of usage examples for org.hibernate.cfg AvailableSettings USE_SECOND_LEVEL_CACHE
String USE_SECOND_LEVEL_CACHE
To view the source code for org.hibernate.cfg AvailableSettings USE_SECOND_LEVEL_CACHE.
Click Source Link
From source file:com.github.javarch.persistence.orm.hibernate.conf.HibernatePropertiesConfig.java
License:Apache License
/** * Retorna um objeto Properties com todas as configuraes de propriedades que devem * ser passadas ao {@link SessionFactory}. As propriedades so definidas no arquivo * hibernate.properties que deve estar presente no raiz do classpath. * /*from w w w. jav a 2 s .c o m*/ * @return Properties do Hibernate. */ @Bean public Properties hibernateProperties() { Properties props = new Properties(); props.put(AvailableSettings.DIALECT, env.getRequiredProperty(AvailableSettings.DIALECT)); if (env.acceptsProfiles(Profiles.TEST)) { props.put(AvailableSettings.HBM2DDL_AUTO, env.getProperty(AvailableSettings.HBM2DDL_AUTO, "update")); } if (env.acceptsProfiles(Profiles.MULT_TENANT)) { if (log.isDebugEnabled()) { log.debug("Profile Multi Tenancy ativado! Realizando configurao..."); } if (currentIdentifierResolver == null || env.acceptsProfiles(Profiles.PRODUCTION)) { throw new DatabaseConfigurationException( "No foi encontrado nenhum objeto CurrentIdentifierResolver."); } props.put(AvailableSettings.MULTI_TENANT_IDENTIFIER_RESOLVER, currentIdentifierResolver); props.put(AvailableSettings.DATASOURCE, env.getRequiredProperty(AvailableSettings.DATASOURCE)); props.put(AvailableSettings.MULTI_TENANT_CONNECTION_PROVIDER, multiTenantConnectionProvider); props.put(AvailableSettings.MULTI_TENANT, env.getRequiredProperty(AvailableSettings.MULTI_TENANT)); } else { props.put(AvailableSettings.USE_SECOND_LEVEL_CACHE, true); props.put(AvailableSettings.USE_QUERY_CACHE, true); props.put(AvailableSettings.CACHE_REGION_FACTORY, "org.hibernate.cache.ehcache.EhCacheRegionFactory"); } if (env.acceptsProfiles(Profiles.ENVERS)) { props.put("org.hibernate.envers.versionsTableSuffix", "_audit"); props.put("org.hibernate.envers.revisionFieldName", "revision"); props.put("org.hibernate.envers.default_schema", "audit"); } return props; }
From source file:debop4k.data.orm.spring.boot.autoconfigure.HibernateProperties.java
License:Apache License
@SneakyThrows({ IOException.class }) public Properties toProperties() { Properties props = new Properties(); props.put(AvailableSettings.DIALECT, dialect); props.put(AvailableSettings.HBM2DDL_AUTO, hbm2ddl); props.put(AvailableSettings.SHOW_SQL, showSql); props.put(AvailableSettings.FORMAT_SQL, formatSql); props.put(AvailableSettings.DEFAULT_BATCH_FETCH_SIZE, batchFetchSize); if (Stringx.isNotEmpty(isolation)) { props.put(AvailableSettings.ISOLATION, isolation); }//from w ww. ja v a 2s . c o m props.put(AvailableSettings.AUTOCOMMIT, autoCommit); props.put(AvailableSettings.RELEASE_CONNECTIONS, releaseMode); props.put(AvailableSettings.USE_SECOND_LEVEL_CACHE, useSecondCache); props.put(AvailableSettings.CACHE_PROVIDER_CONFIG, cacheProviderConfig.getFile().getAbsolutePath()); return props; }
From source file:org.infinispan.test.hibernate.cache.commons.util.CacheTestUtil.java
License:LGPL
@SuppressWarnings("unchecked") public static Map buildBaselineSettings(String regionPrefix, boolean use2ndLevel, boolean useQueries, Class<? extends JtaPlatform> jtaPlatform) { Map settings = new HashMap(); settings.put(AvailableSettings.GENERATE_STATISTICS, "true"); settings.put(AvailableSettings.USE_STRUCTURED_CACHE, "true"); if (jtaPlatform == null || jtaPlatform == NoJtaPlatform.class) { settings.put(Environment.TRANSACTION_COORDINATOR_STRATEGY, JdbcResourceLocalTransactionCoordinatorBuilderImpl.class.getName()); settings.put(AvailableSettings.JTA_PLATFORM, NoJtaPlatform.class); } else {/*from w w w. j a va 2 s .co m*/ settings.put(Environment.TRANSACTION_COORDINATOR_STRATEGY, JtaTransactionCoordinatorBuilderImpl.class.getName()); settings.put(AvailableSettings.JTA_PLATFORM, jtaPlatform); } settings.put(AvailableSettings.CACHE_REGION_FACTORY, TestRegionFactoryProvider.load().getRegionFactoryClass()); settings.put(AvailableSettings.CACHE_REGION_PREFIX, regionPrefix); settings.put(AvailableSettings.USE_SECOND_LEVEL_CACHE, String.valueOf(use2ndLevel)); settings.put(AvailableSettings.USE_QUERY_CACHE, String.valueOf(useQueries)); return settings; }
From source file:org.infinispan.test.hibernate.cache.util.CacheTestUtil.java
License:LGPL
@SuppressWarnings("unchecked") public static Map buildBaselineSettings(String regionPrefix, Class regionFactory, boolean use2ndLevel, boolean useQueries, Class<? extends JtaPlatform> jtaPlatform) { Map settings = new HashMap(); settings.put(AvailableSettings.GENERATE_STATISTICS, "true"); settings.put(AvailableSettings.USE_STRUCTURED_CACHE, "true"); if (jtaPlatform == null) { settings.put(Environment.TRANSACTION_COORDINATOR_STRATEGY, JdbcResourceLocalTransactionCoordinatorBuilderImpl.class.getName()); } else {//from w w w . j a va2s . c o m settings.put(Environment.TRANSACTION_COORDINATOR_STRATEGY, JtaTransactionCoordinatorBuilderImpl.class.getName()); settings.put(AvailableSettings.JTA_PLATFORM, jtaPlatform); } settings.put(AvailableSettings.CACHE_REGION_FACTORY, regionFactory.getName()); settings.put(AvailableSettings.CACHE_REGION_PREFIX, regionPrefix); settings.put(AvailableSettings.USE_SECOND_LEVEL_CACHE, String.valueOf(use2ndLevel)); settings.put(AvailableSettings.USE_QUERY_CACHE, String.valueOf(useQueries)); return settings; }
From source file:org.jboss.as.jpa.hibernate4.HibernatePersistenceProviderAdaptor.java
License:Open Source License
@Override public void addProviderDependencies(PersistenceUnitMetadata pu) { final Properties properties = pu.getProperties(); final String sharedCacheMode = properties.getProperty(SHARED_CACHE_MODE); if (Classification.NONE.equals(platform.defaultCacheClassification())) { if (!SharedCacheMode.NONE.equals(pu.getSharedCacheMode())) { JPA_LOGGER.tracef("second level cache is not supported in platform, ignoring shared cache mode"); }/* w ww . ja v a 2s . c o m*/ pu.setSharedCacheMode(SharedCacheMode.NONE); } // check if 2lc is explicitly disabled which takes precedence over other settings boolean sharedCacheDisabled = SharedCacheMode.NONE.equals(pu.getSharedCacheMode()) || NONE.equals(sharedCacheMode); if (!sharedCacheDisabled && Boolean.parseBoolean(properties.getProperty(AvailableSettings.USE_SECOND_LEVEL_CACHE)) || (sharedCacheMode != null && (!NONE.equals(sharedCacheMode))) || (!SharedCacheMode.NONE.equals(pu.getSharedCacheMode()) && (!SharedCacheMode.UNSPECIFIED.equals(pu.getSharedCacheMode())))) { HibernateSecondLevelCache.addSecondLevelCacheDependencies(pu.getProperties(), pu.getScopedPersistenceUnitName()); JPA_LOGGER.tracef("second level cache enabled for %s", pu.getScopedPersistenceUnitName()); } else { JPA_LOGGER.tracef("second level cache disabled for %s, pu %s property = %s, pu.getSharedCacheMode = %s", pu.getScopedPersistenceUnitName(), SHARED_CACHE_MODE, sharedCacheMode, pu.getSharedCacheMode().toString()); } }