org.hibernate.cfg.Settings Java Examples

The following examples show how to use org.hibernate.cfg.Settings. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Hibernate4MemcachedRegionFactory.java    From hibernate4-memcached with Apache License 2.0 6 votes vote down vote up
HibernateCacheTimestamper populateTimestamper(Settings settings, OverridableReadOnlyProperties properties) {
    String timestamperClazzName = properties.getProperty(TIMESTAMPER_PROPERTY_KEY,
            DEFAULT_TIMESTAMPER_CLASS.getName());

    HibernateCacheTimestamper timestamper;
    try {
        Class<?> clazz = Class.forName(timestamperClazzName);
        timestamper = (HibernateCacheTimestamper) clazz.newInstance();
    } catch (Exception e) {
        throw new IllegalStateException(e.getMessage(), e);
    }

    timestamper.setSettings(settings);
    timestamper.setProperties(properties);
    timestamper.setMemcachedAdapter(memcachedAdapter);
    timestamper.init();
    return timestamper;
}
 
Example #2
Source File: StandardQueryCache.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public StandardQueryCache(
		final Settings settings, 
		final Properties props, 
		final UpdateTimestampsCache updateTimestampsCache, 
		String regionName) throws HibernateException {
	if ( regionName == null ) {
		regionName = StandardQueryCache.class.getName();
	}
	String prefix = settings.getCacheRegionPrefix();
	if ( prefix != null ) {
		regionName = prefix + '.' + regionName;
	}
	log.info( "starting query cache at region: " + regionName );

	this.queryCache = settings.getCacheProvider().buildCache(regionName, props);
	this.updateTimestampsCache = updateTimestampsCache;
	this.regionName = regionName;
}
 
Example #3
Source File: MemcachedRegionAccessStrategyTest.java    From hibernate4-memcached with Apache License 2.0 5 votes vote down vote up
@Test
public void putFromLoad_without_minimalPutOverride() throws Exception {
    Settings settings = new TestingSettingsBuilder().setField("minimalPutsEnabled", true).build();
    when(generalDataMemcachedRegion.getSettings()).thenReturn(settings);

    memcachedRegionAccessStrategy.putFromLoad("books#1", "book 1", 1L, "version object");

    verify(memcachedRegionAccessStrategy).putFromLoad("books#1", "book 1", 1L, "version object", true);
}
 
Example #4
Source File: MemcachedRegion.java    From hibernate4-memcached with Apache License 2.0 5 votes vote down vote up
public MemcachedRegion(CacheNamespace cacheNamespace, OverridableReadOnlyProperties properties, CacheDataDescription metadata, Settings settings,
                       MemcachedAdapter memcachedAdapter, HibernateCacheTimestamper hibernateCacheTimestamper) {
    this.cacheNamespace = cacheNamespace;
    this.properties = properties;
    this.metadata = metadata;
    this.settings = settings;
    this.memcachedAdapter = memcachedAdapter;
    this.hibernateCacheTimestamper = hibernateCacheTimestamper;
}
 
Example #5
Source File: SchemaExport.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Create a schema exporter for the given Configuration
 * and given settings
 */
public SchemaExport(Configuration cfg, Settings settings) throws HibernateException {
	dialect = settings.getDialect();
	connectionHelper = new SuppliedConnectionProviderConnectionHelper(
			settings.getConnectionProvider()
	);
	dropSQL = cfg.generateDropSchemaScript( dialect );
	createSQL = cfg.generateSchemaCreationScript( dialect );
	format = settings.isFormatSqlEnabled();
}
 
Example #6
Source File: LocalSessionFactoryBuilder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Settings buildSettings(Properties props, ServiceRegistry serviceRegistry) throws HibernateException {
	Settings settings = super.buildSettings(props, serviceRegistry);
	if (this.cacheRegionFactory != null) {
		try {
			Method setRegionFactory = Settings.class.getDeclaredMethod("setRegionFactory", RegionFactory.class);
			setRegionFactory.setAccessible(true);
			setRegionFactory.invoke(settings, this.cacheRegionFactory);
		}
		catch (Exception ex) {
			throw new IllegalStateException("Failed to invoke Hibernate's setRegionFactory method", ex);
		}
	}
	return settings;
}
 
Example #7
Source File: SchemaValidator.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public SchemaValidator(Configuration cfg, Settings settings) throws HibernateException {
	this.configuration = cfg;
	dialect = settings.getDialect();
	connectionHelper = new SuppliedConnectionProviderConnectionHelper(
			settings.getConnectionProvider()
	);
}
 
Example #8
Source File: NaturalIdMemcachedRegion.java    From hibernate4-memcached with Apache License 2.0 5 votes vote down vote up
public NaturalIdMemcachedRegion(String regionName, OverridableReadOnlyProperties properties,
                                CacheDataDescription metadata, Settings settings,
                                MemcachedAdapter memcachedAdapter,
                                HibernateCacheTimestamper hibernateCacheTimestamper) {
    super(new CacheNamespace(regionName, true), properties, metadata, settings, memcachedAdapter,
          hibernateCacheTimestamper);
}
 
Example #9
Source File: LocalSessionFactoryBuilder.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public Settings buildSettings(Properties props, ServiceRegistry serviceRegistry) throws HibernateException {
	Settings settings = super.buildSettings(props, serviceRegistry);
	if (this.cacheRegionFactory != null) {
		try {
			Method setRegionFactory = Settings.class.getDeclaredMethod("setRegionFactory", RegionFactory.class);
			setRegionFactory.setAccessible(true);
			setRegionFactory.invoke(settings, this.cacheRegionFactory);
		}
		catch (Exception ex) {
			throw new IllegalStateException("Failed to invoke Hibernate's setRegionFactory method", ex);
		}
	}
	return settings;
}
 
Example #10
Source File: MemcachedRegionAccessStrategyTest.java    From hibernate4-memcached with Apache License 2.0 5 votes vote down vote up
@Test
public void isMinimalPutsEnabled_false() throws Exception {
    Settings settings = new TestingSettingsBuilder().setField("minimalPutsEnabled", false).build();
    when(generalDataMemcachedRegion.getSettings()).thenReturn(settings);

    assertThat(memcachedRegionAccessStrategy.isMinimalPutsEnabled()).isFalse();
}
 
Example #11
Source File: RedissonRegionFactory.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Override
public void start(SessionFactoryOptions settings, Properties properties) throws CacheException {
    this.redisson = createRedissonClient(properties);
    this.settings = new Settings(settings);

    StrategySelector selector = settings.getServiceRegistry().getService(StrategySelector.class);
    cacheKeysFactory = selector.resolveDefaultableStrategy(CacheKeysFactory.class,
                            properties.get(Environment.CACHE_KEYS_FACTORY), new RedissonCacheKeysFactory(redisson.getConfig().getCodec()));

}
 
Example #12
Source File: Hibernate4MemcachedRegionFactory.java    From hibernate4-memcached with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Settings settings, Properties properties) throws CacheException {
    log.debug("# start Hibernate4MemcachedRegionFactory.");

    this.settings = settings;
    cacheProviderConfigProperties = populateCacheProviderConfigProperties(properties);
    OverridableReadOnlyProperties mergedConfigProperties = new OverridableReadOnlyPropertiesImpl(properties,
            cacheProviderConfigProperties);
    memcachedAdapter = populateMemcachedProvider(mergedConfigProperties);
    hibernateCacheTimestamper = populateTimestamper(settings, mergedConfigProperties);
}
 
Example #13
Source File: HibernateRegionFactory.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public void start(Settings settings, Properties props) throws CacheException {
    String accessType = props.getProperty(DFLT_ACCESS_TYPE_PROPERTY, NONSTRICT_READ_WRITE.name());

    dfltAccessType = AccessType.valueOf(accessType);

    accessStgyFactory.start(props);
}
 
Example #14
Source File: IgniteStandardQueryCacheFactory.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@Override
public QueryCache getQueryCache(
        final String regionName,
        final UpdateTimestampsCache updateTimestampsCache,
        final Settings settings,
        final Properties props) throws HibernateException {
    return new IgniteStandardQueryCache(settings, props, updateTimestampsCache, regionName);
}
 
Example #15
Source File: J2CacheRegionFactory.java    From J2Cache with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Settings settings, Properties properties) throws CacheException {
    this.settings = settings;
    if (this.channel == null) {
        this.channel = J2Cache.getChannel();
    }
}
 
Example #16
Source File: IgniteStandardQueryCacheFactory.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@Override
public QueryCache getQueryCache(
        final String regionName,
        final UpdateTimestampsCache updateTimestampsCache,
        final Settings settings,
        final Properties props) throws HibernateException {
    return new IgniteStandardQueryCache(settings, props, updateTimestampsCache, regionName);
}
 
Example #17
Source File: ReadOnlyCollectionRegionAccessStrategy.java    From redisson with Apache License 2.0 4 votes vote down vote up
public ReadOnlyCollectionRegionAccessStrategy(Settings settings, GeneralDataRegion region) {
    super(settings, region);
}
 
Example #18
Source File: BaseRegionAccessStrategy.java    From redisson with Apache License 2.0 4 votes vote down vote up
BaseRegionAccessStrategy(Settings settings, GeneralDataRegion region) {
    this.settings = settings;
    this.region = region;
}
 
Example #19
Source File: ReadWriteNaturalIdRegionAccessStrategy.java    From redisson with Apache License 2.0 4 votes vote down vote up
public ReadWriteNaturalIdRegionAccessStrategy(Settings settings, GeneralDataRegion region,
        RMapCache<Object, Object> mapCache) {
    super(settings, region, mapCache);
}
 
Example #20
Source File: RedissonEntityRegion.java    From redisson with Apache License 2.0 4 votes vote down vote up
public RedissonEntityRegion(RMapCache<Object, Object> mapCache, ConnectionManager connectionManager, RegionFactory regionFactory,
                            CacheDataDescription metadata, Settings settings, Properties properties, String defaultKey, CacheKeysFactory cacheKeysFactory) {
    super(mapCache, connectionManager, regionFactory, metadata, properties, defaultKey);
    this.settings = settings;
    this.cacheKeysFactory = cacheKeysFactory;
}
 
Example #21
Source File: ReadOnlyEntityRegionAccessStrategy.java    From redisson with Apache License 2.0 4 votes vote down vote up
public ReadOnlyEntityRegionAccessStrategy(Settings settings, GeneralDataRegion region) {
    super(settings, region);
}
 
Example #22
Source File: TransactionalEntityRegionAccessStrategy.java    From redisson with Apache License 2.0 4 votes vote down vote up
public TransactionalEntityRegionAccessStrategy(Settings settings, GeneralDataRegion region) {
    super(settings, region);
}
 
Example #23
Source File: NonStrictReadWriteEntityRegionAccessStrategy.java    From redisson with Apache License 2.0 4 votes vote down vote up
public NonStrictReadWriteEntityRegionAccessStrategy(Settings settings, GeneralDataRegion region) {
    super(settings, region);
}
 
Example #24
Source File: GeneralDataMemcachedRegion.java    From hibernate4-memcached with Apache License 2.0 4 votes vote down vote up
public GeneralDataMemcachedRegion(CacheNamespace cacheNamespace, OverridableReadOnlyProperties properties, CacheDataDescription metadata,
                                  Settings settings, MemcachedAdapter memcachedAdapter, HibernateCacheTimestamper hibernateCacheTimestamper) {
    super(cacheNamespace, properties, metadata, settings, memcachedAdapter, hibernateCacheTimestamper);
    populateExpirySeconds(properties);
}
 
Example #25
Source File: ReadOnlyEntityRegionAccessStrategy.java    From redisson with Apache License 2.0 4 votes vote down vote up
public ReadOnlyEntityRegionAccessStrategy(Settings settings, GeneralDataRegion region) {
    super(settings, region);
}
 
Example #26
Source File: ReadWriteEntityRegionAccessStrategy.java    From redisson with Apache License 2.0 4 votes vote down vote up
public ReadWriteEntityRegionAccessStrategy(Settings settings, GeneralDataRegion region, RMapCache<Object, Object> mapCache) {
    super(settings, region, mapCache);
}
 
Example #27
Source File: ReadWriteCollectionRegionAccessStrategy.java    From redisson with Apache License 2.0 4 votes vote down vote up
public ReadWriteCollectionRegionAccessStrategy(Settings settings, GeneralDataRegion region,
        RMapCache<Object, Object> mapCache) {
    super(settings, region, mapCache);
}
 
Example #28
Source File: TransactionalNaturalIdRegionAccessStrategy.java    From redisson with Apache License 2.0 4 votes vote down vote up
public TransactionalNaturalIdRegionAccessStrategy(Settings settings, GeneralDataRegion region) {
    super(settings, region);
}
 
Example #29
Source File: AbstractReadWriteAccessStrategy.java    From redisson with Apache License 2.0 4 votes vote down vote up
public AbstractReadWriteAccessStrategy(Settings settings, GeneralDataRegion region, RMapCache<Object, Object> mapCache) {
    super(settings, region);
    this.mapCache = mapCache;
}
 
Example #30
Source File: HibernateCacheTimestamperMemcachedImpl.java    From hibernate4-memcached with Apache License 2.0 4 votes vote down vote up
@Override
public void setSettings(Settings settings) {
    this.settings = settings;
}