Example usage for org.hibernate.cache.cfg.spi DomainDataRegionConfig getEntityCaching

List of usage examples for org.hibernate.cache.cfg.spi DomainDataRegionConfig getEntityCaching

Introduction

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

Prototype

List<EntityDataCachingConfig> getEntityCaching();

Source Link

Document

Retrieve the list of all entity to be stored in this region

Usage

From source file:org.infinispan.hibernate.cache.v53.InfinispanRegionFactory.java

License:LGPL

@Override
public DomainDataRegion buildDomainDataRegion(DomainDataRegionConfig regionConfig,
        DomainDataRegionBuildingContext buildingContext) {
    log.debugf("Building domain data region [%s] entities=%s collections=%s naturalIds=%s",
            regionConfig.getRegionName(), regionConfig.getEntityCaching(), regionConfig.getCollectionCaching(),
            regionConfig.getNaturalIdCaching());
    // TODO: data type is probably deprecated, but we need it for backwards-compatible configuration
    DataType dataType;// w w  w .  j ava  2s .c  o m
    int entities = regionConfig.getEntityCaching().size();
    int collections = regionConfig.getCollectionCaching().size();
    int naturalIds = regionConfig.getNaturalIdCaching().size();
    if (entities > 0 && collections == 0 && naturalIds == 0) {
        dataType = regionConfig.getEntityCaching().stream().allMatch(c -> !c.isMutable())
                ? DataType.IMMUTABLE_ENTITY
                : DataType.ENTITY;
    } else if (entities == 0 && collections > 0 && naturalIds == 0) {
        dataType = DataType.COLLECTION;
    } else if (entities == 0 && collections == 0 && naturalIds > 0) {
        dataType = DataType.NATURAL_ID;
    } else {
        // some mix, let's use entity
        dataType = DataType.ENTITY;
    }

    AdvancedCache cache = getCache(qualify(regionConfig.getRegionName()), regionConfig.getRegionName(),
            dataType, Collections.emptyList());
    DomainDataRegionImpl region = new DomainDataRegionImpl(cache, regionConfig, this, getCacheKeysFactory());
    startRegion(region);
    return region;
}

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

License:Apache License

@Override
protected DomainDataStorageAccess createDomainDataStorageAccess(DomainDataRegionConfig regionConfig,
        DomainDataRegionBuildingContext buildingContext) {
    String defaultKey = null;//from  w  w  w .  j  a  v a2  s.co  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);
}