Example usage for org.hibernate.cache.cfg.spi DomainDataRegionBuildingContext getSessionFactory

List of usage examples for org.hibernate.cache.cfg.spi DomainDataRegionBuildingContext getSessionFactory

Introduction

In this page you can find the example usage for org.hibernate.cache.cfg.spi DomainDataRegionBuildingContext getSessionFactory.

Prototype

SessionFactoryImplementor getSessionFactory();

Source Link

Document

Access to the SessionFactory for which a Region is being built.

Usage

From source file:org.redisson.hibernate.RedissonRegionFactory.java

License:Apache License

@Override
protected DomainDataStorageAccess createDomainDataStorageAccess(DomainDataRegionConfig regionConfig,
        DomainDataRegionBuildingContext buildingContext) {
    String defaultKey = null;/* w  w  w  .  j a  va  2  s.c o  m*/
    if (!regionConfig.getCollectionCaching().isEmpty()) {
        defaultKey = COLLECTION_DEF;
    } else if (!regionConfig.getEntityCaching().isEmpty()) {
        defaultKey = ENTITY_DEF;
    } else if (!regionConfig.getNaturalIdCaching().isEmpty()) {
        defaultKey = NATURAL_ID_DEF;
    } else {
        throw new IllegalArgumentException("Unable to determine entity cache type!");
    }

    RMapCache<Object, Object> mapCache = getCache(regionConfig.getRegionName(),
            buildingContext.getSessionFactory().getProperties(), defaultKey);
    return new RedissonStorage(mapCache, buildingContext.getSessionFactory().getProperties(), defaultKey);
}