Example usage for org.hibernate.cache.internal NoCachingRegionFactory INSTANCE

List of usage examples for org.hibernate.cache.internal NoCachingRegionFactory INSTANCE

Introduction

In this page you can find the example usage for org.hibernate.cache.internal NoCachingRegionFactory INSTANCE.

Prototype

NoCachingRegionFactory INSTANCE

To view the source code for org.hibernate.cache.internal NoCachingRegionFactory INSTANCE.

Click Source Link

Document

Singleton access

Usage

From source file:org.jboss.as.jpa.hibernate5.service.CustomRegionFactoryInitiator.java

License:LGPL

@Override
protected RegionFactory getFallback(Map configurationValues, ServiceRegistryImplementor registry) {
    return NoCachingRegionFactory.INSTANCE;
}

From source file:org.jboss.as.jpa.hibernate5.service.WildFlyCustomRegionFactoryInitiator.java

License:Apache License

@Override
protected RegionFactory resolveRegionFactory(Map configurationValues, ServiceRegistryImplementor registry) {
    final Object useSecondLevelCache = configurationValues.get(USE_SECOND_LEVEL_CACHE);
    final String jpaSharedCodeModeValue = configurationValues.get(JPA_SHARED_CACHE_MODE) != null
            ? configurationValues.get(JPA_SHARED_CACHE_MODE).toString()
            : UNSPECIFIED;/*from w  w w  .jav  a  2 s . c  o  m*/
    final Object regionFactory = configurationValues.get(HIBERNATE_REGION_FACTORY_CLASS);

    // treat Hibernate 2lc as off, if not specified.
    // Note that Hibernate 2lc in 5.1.x, defaults to disabled, so this code is only needed in 5.3.x+.
    if (Boolean.parseBoolean((String) useSecondLevelCache)) {
        JPA_LOGGER.tracef(
                "WildFlyCustomRegionFactoryInitiator#resolveRegionFactory using %s for 2lc, useSecondLevelCache=%s, jpaSharedCodeModeValue=%s, regionFactory=%s",
                V53_INFINISPAN_REGION_FACTORY, useSecondLevelCache, jpaSharedCodeModeValue, regionFactory);
        configurationValues.put(HIBERNATE_REGION_FACTORY_CLASS, V53_INFINISPAN_REGION_FACTORY);
        return super.resolveRegionFactory(configurationValues, registry);
    } else if (UNSPECIFIED.equals(jpaSharedCodeModeValue) || NONE.equals(jpaSharedCodeModeValue)) {
        // explicitly disable 2lc cache
        JPA_LOGGER.tracef(
                "WildFlyCustomRegionFactoryInitiator#resolveRegionFactory not using a 2lc, useSecondLevelCache=%s, jpaSharedCodeModeValue=%s, regionFactory=%s",
                useSecondLevelCache, jpaSharedCodeModeValue, regionFactory);
        return NoCachingRegionFactory.INSTANCE;
    } else {
        JPA_LOGGER.tracef(
                "WildFlyCustomRegionFactoryInitiator#resolveRegionFactory using %s for 2lc, useSecondLevelCache=%s, jpaSharedCodeModeValue=%s, regionFactory=%s",
                V53_INFINISPAN_REGION_FACTORY, useSecondLevelCache, jpaSharedCodeModeValue, regionFactory);
        configurationValues.put(HIBERNATE_REGION_FACTORY_CLASS, V53_INFINISPAN_REGION_FACTORY);
        return super.resolveRegionFactory(configurationValues, registry);
    }
}