org.hibernate.cache.spi.DomainDataRegion Java Examples

The following examples show how to use org.hibernate.cache.spi.DomainDataRegion. 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: NaturalIdNonStrictReadWriteAccess.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public NaturalIdNonStrictReadWriteAccess(
		DomainDataRegion region,
		CacheKeysFactory keysFactory,
		DomainDataStorageAccess storageAccess,
		NaturalIdDataCachingConfig config) {
	super( region, keysFactory, storageAccess, config );
}
 
Example #2
Source File: RedissonRegionFactory.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Override
public DomainDataRegion buildDomainDataRegion(
        DomainDataRegionConfig regionConfig,
        DomainDataRegionBuildingContext buildingContext) {
    verifyStarted();
    return new DomainDataRegionImpl(
            regionConfig,
            this,
            createDomainDataStorageAccess( regionConfig, buildingContext ),
            getImplicitCacheKeysFactory(),
            buildingContext
    );
}
 
Example #3
Source File: ReadWriteCacheConcurrencyStrategyWithLockTimeoutTest.java    From high-performance-java-persistence with Apache License 2.0 5 votes vote down vote up
private net.sf.ehcache.Cache getCache(Class clazz) throws IllegalAccessException {
    EntityPersister entityPersister = ((SessionFactoryImplementor) sessionFactory()).getEntityPersister(clazz.getName() );
    DomainDataRegion region = entityPersister.getCacheAccessStrategy().getRegion();
    Field storageAccessField = getField(region.getClass(), "storageAccess");
    StorageAccess storageAccess = (StorageAccess) storageAccessField.get(region);
    Field cacheField = getField(storageAccess.getClass(), "cache");
    return  (net.sf.ehcache.Cache) cacheField.get(storageAccess);
}
 
Example #4
Source File: IgniteCollectionDataAccess.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param stgy Access strategy implementation.
 * @param accessType Strategy access type.
 * @param regionFactory Region factory.
 * @param domainDataRegion Data region.
 * @param ignite Ignite instance.
 * @param cache Cache proxy.
 */
public IgniteCollectionDataAccess(
    HibernateAccessStrategyAdapter stgy,
    AccessType accessType,
    RegionFactory regionFactory,
    DomainDataRegion domainDataRegion,
    Ignite ignite,
    HibernateCacheProxy cache
) {
    super(stgy, regionFactory, domainDataRegion, ignite, cache);

    this.accessType = accessType;
}
 
Example #5
Source File: IgniteNaturalIdDataAccess.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** */
public IgniteNaturalIdDataAccess(
    HibernateAccessStrategyAdapter stgy,
    AccessType accessType,
    RegionFactory regionFactory,
    DomainDataRegion domainDataRegion,
    Ignite ignite,
    HibernateCacheProxy cache
) {
    super(stgy, regionFactory, domainDataRegion, ignite, cache);

    this.accessType = accessType;
}
 
Example #6
Source File: HibernateRegionFactory.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public DomainDataRegion buildDomainDataRegion(
    DomainDataRegionConfig regionCfg,
    DomainDataRegionBuildingContext buildingCtx) {
    return new IgniteDomainDataRegion(regionCfg, this, null, buildingCtx,
        accessStgyFactory);
}
 
Example #7
Source File: IgniteCachedDomainDataAccess.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param stgy Access strategy implementation.
 */
protected IgniteCachedDomainDataAccess(HibernateAccessStrategyAdapter stgy,
    RegionFactory regionFactory,
    DomainDataRegion domainDataRegion,
    Ignite ignite, HibernateCacheProxy cache) {
    super(regionFactory, cache.name(), ignite, cache);

    this.stgy = stgy;
    this.domainDataRegion = domainDataRegion;
}
 
Example #8
Source File: IgniteEntityDataAccess.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** */
public IgniteEntityDataAccess(
    HibernateAccessStrategyAdapter stgy,
    AccessType accessType,
    RegionFactory regionFactory,
    DomainDataRegion domainDataRegion,
    Ignite ignite,
    HibernateCacheProxy cache
) {
    super(stgy, regionFactory, domainDataRegion, ignite, cache);

    this.accessType = accessType;
}
 
Example #9
Source File: CollectionTransactionAccess.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public CollectionTransactionAccess(
		DomainDataRegion region,
		CacheKeysFactory keysFactory,
		DomainDataStorageAccess storageAccess,
		CollectionDataCachingConfig config) {
	super( region, keysFactory, storageAccess, config );
}
 
Example #10
Source File: RegionFactoryTemplate.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public DomainDataRegion buildDomainDataRegion(
		DomainDataRegionConfig regionConfig,
		DomainDataRegionBuildingContext buildingContext) {
	verifyStarted();
	return new DomainDataRegionTemplate(
			regionConfig,
			this,
			createDomainDataStorageAccess( regionConfig, buildingContext ),
			getImplicitCacheKeysFactory(),
			buildingContext
	);
}
 
Example #11
Source File: EntityNonStrictReadWriteAccess.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public EntityNonStrictReadWriteAccess(
		DomainDataRegion domainDataRegion,
		CacheKeysFactory keysFactory,
		DomainDataStorageAccess storageAccess,
		EntityDataCachingConfig entityAccessConfig) {
	super( domainDataRegion, keysFactory, storageAccess );
}
 
Example #12
Source File: DeprecatedNaturalIdCacheStatisticsImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long getElementCountInMemory() {
	long count = 0;
	HashSet<Region> processedRegions = null;

	for ( NaturalIdDataAccess accessStrategy : accessStrategies ) {
		final DomainDataRegion region = accessStrategy.getRegion();
		if ( ExtendedStatisticsSupport.class.isInstance( region ) ) {

		}

		if ( region instanceof ExtendedStatisticsSupport ) {
			if ( processedRegions == null ) {
				processedRegions = new HashSet<>();
			}
			if ( processedRegions.add( region ) ) {
				count += ( (ExtendedStatisticsSupport) region ).getElementCountInMemory();
			}
		}

	}

	if ( count == 0 ) {
		return NO_EXTENDED_STAT_SUPPORT_RETURN;
	}

	return count;
}
 
Example #13
Source File: AbstractCollectionDataAccess.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public AbstractCollectionDataAccess(
		DomainDataRegion region,
		CacheKeysFactory keysFactory,
		DomainDataStorageAccess storageAccess,
		CollectionDataCachingConfig config) {
	super( region, storageAccess );
	this.keysFactory = keysFactory;
}
 
Example #14
Source File: CollectionReadWriteAccess.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public CollectionReadWriteAccess(
		DomainDataRegion region,
		CacheKeysFactory keysFactory,
		DomainDataStorageAccess storageAccess,
		CollectionDataCachingConfig config) {
	super( region, storageAccess );
	this.keysFactory = keysFactory;
	this.collectionRole = config.getNavigableRole();
	this.versionComparator = config.getOwnerVersionComparator();
}
 
Example #15
Source File: EntityReadOnlyAccess.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public EntityReadOnlyAccess(
		DomainDataRegion region,
		CacheKeysFactory cacheKeysFactory,
		DomainDataStorageAccess storageAccess,
		EntityDataCachingConfig config) {
	super( region, cacheKeysFactory, storageAccess );
	if ( config.isMutable() ) {
		SecondLevelCacheLogger.INSTANCE.readOnlyCachingMutableEntity( config.getNavigableRole() );
	}
}
 
Example #16
Source File: DeprecatedNaturalIdCacheStatisticsImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long getElementCountOnDisk() {
	long count = 0;
	HashSet<Region> processedRegions = null;

	for ( NaturalIdDataAccess accessStrategy : accessStrategies ) {
		final DomainDataRegion region = accessStrategy.getRegion();
		if ( ExtendedStatisticsSupport.class.isInstance( region ) ) {

		}

		if ( region instanceof ExtendedStatisticsSupport ) {
			if ( processedRegions == null ) {
				processedRegions = new HashSet<>();
			}
			if ( processedRegions.add( region ) ) {
				count += ( (ExtendedStatisticsSupport) region ).getElementCountOnDisk();
			}
		}

	}

	if ( count == 0 ) {
		return NO_EXTENDED_STAT_SUPPORT_RETURN;
	}

	return count;
}
 
Example #17
Source File: DeprecatedNaturalIdCacheStatisticsImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long getSizeInMemory() {
	long count = 0;
	HashSet<Region> processedRegions = null;

	for ( NaturalIdDataAccess accessStrategy : accessStrategies ) {
		final DomainDataRegion region = accessStrategy.getRegion();
		if ( ExtendedStatisticsSupport.class.isInstance( region ) ) {

		}

		if ( region instanceof ExtendedStatisticsSupport ) {
			if ( processedRegions == null ) {
				processedRegions = new HashSet<>();
			}
			if ( processedRegions.add( region ) ) {
				count += ( (ExtendedStatisticsSupport) region ).getElementCountOnDisk();
			}
		}

	}

	if ( count == 0 ) {
		return NO_EXTENDED_STAT_SUPPORT_RETURN;
	}

	return count;
}
 
Example #18
Source File: NaturalIdTransactionalAccess.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public NaturalIdTransactionalAccess(
		DomainDataRegion region,
		CacheKeysFactory keysFactory,
		DomainDataStorageAccess storageAccess,
		NaturalIdDataCachingConfig config) {
	super( region, keysFactory, storageAccess, config );
}
 
Example #19
Source File: CollectionNonStrictReadWriteAccess.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public CollectionNonStrictReadWriteAccess(
		DomainDataRegion region,
		CacheKeysFactory keysFactory,
		DomainDataStorageAccess storageAccess,
		CollectionDataCachingConfig config) {
	super( region, keysFactory, storageAccess, config );
}
 
Example #20
Source File: AbstractEntityDataAccess.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public AbstractEntityDataAccess(
		DomainDataRegion region,
		CacheKeysFactory cacheKeysFactory,
		DomainDataStorageAccess storageAccess) {
	super( region, storageAccess );
	this.cacheKeysFactory = cacheKeysFactory;
}
 
Example #21
Source File: NaturalIdReadWriteAccess.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public NaturalIdReadWriteAccess(
		DomainDataRegion region,
		CacheKeysFactory keysFactory,
		DomainDataStorageAccess storageAccess,
		NaturalIdDataCachingConfig naturalIdDataCachingConfig) {
	super( region, storageAccess );
	this.keysFactory = keysFactory;
}
 
Example #22
Source File: EntityTransactionalAccess.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public EntityTransactionalAccess(
		DomainDataRegion region,
		CacheKeysFactory keysFactory,
		DomainDataStorageAccess storageAccess,
		EntityDataCachingConfig accessConfig) {
	super( region, keysFactory, storageAccess );
}
 
Example #23
Source File: CollectionReadOnlyAccess.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public CollectionReadOnlyAccess(
		DomainDataRegion region,
		CacheKeysFactory keysFactory,
		DomainDataStorageAccess storageAccess,
		CollectionDataCachingConfig config) {
	super( region, keysFactory, storageAccess, config );
}
 
Example #24
Source File: NaturalIdReadOnlyAccess.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public NaturalIdReadOnlyAccess(
		DomainDataRegion region,
		CacheKeysFactory keysFactory,
		DomainDataStorageAccess storageAccess,
		NaturalIdDataCachingConfig config) {
	super( region, keysFactory, storageAccess, config );
	if ( config.isMutable() ) {
		SecondLevelCacheLogger.INSTANCE.readOnlyCachingMutableNaturalId( config.getNavigableRole() );
	}
}
 
Example #25
Source File: EntityReadWriteAccess.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public EntityReadWriteAccess(
		DomainDataRegion domainDataRegion,
		CacheKeysFactory keysFactory,
		DomainDataStorageAccess storageAccess,
		EntityDataCachingConfig entityAccessConfig) {
	super( domainDataRegion, storageAccess );
	this.keysFactory = keysFactory;
	this.versionComparator = entityAccessConfig.getVersionComparatorAccess() == null
			? null
			: entityAccessConfig.getVersionComparatorAccess().get();
}
 
Example #26
Source File: AbstractNaturalIdDataAccess.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public AbstractNaturalIdDataAccess(
		DomainDataRegion region,
		CacheKeysFactory keysFactory,
		DomainDataStorageAccess storageAccess,
		NaturalIdDataCachingConfig config) {
	super( region, storageAccess );
	this.keysFactory = keysFactory;
}
 
Example #27
Source File: AbstractCachedDomainDataAccess.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public DomainDataRegion getRegion() {
	return region;
}
 
Example #28
Source File: EnabledCaching.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void prime(Set<DomainDataRegionConfig> cacheRegionConfigs) {
	for ( DomainDataRegionConfig regionConfig : cacheRegionConfigs ) {
		final DomainDataRegion region = getRegionFactory().buildDomainDataRegion( regionConfig, this );
		regionsByName.put( region.getName(), region );

		if ( ! Objects.equals( region.getName(), regionConfig.getRegionName() ) ) {
			throw new HibernateException(
					String.format(
							Locale.ROOT,
							"Region [%s] returned from RegionFactory [%s] was named differently than requested name.  Expecting `%s`, but found `%s`",
							region,
							getRegionFactory().getClass().getName(),
							regionConfig.getRegionName(),
							region.getName()
					)
			);
		}

		// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		// Entity caching

		for ( EntityDataCachingConfig entityAccessConfig : regionConfig.getEntityCaching() ) {
			final EntityDataAccess entityDataAccess = entityAccessMap.put(
					entityAccessConfig.getNavigableRole(),
					region.getEntityDataAccess( entityAccessConfig.getNavigableRole() )
			);

			legacySecondLevelCacheNames.add(
					StringHelper.qualifyConditionally(
							getSessionFactory().getSessionFactoryOptions().getCacheRegionPrefix(),
							region.getName()
					)
			);
		}


		// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		// Natural-id caching

		if ( regionConfig.getNaturalIdCaching().isEmpty() ) {
			legacyNaturalIdAccessesForRegion.put( region.getName(), Collections.emptySet() );
		}
		else {
			final HashSet<NaturalIdDataAccess> accesses = new HashSet<>();

			for ( NaturalIdDataCachingConfig naturalIdAccessConfig : regionConfig.getNaturalIdCaching() ) {
				final NaturalIdDataAccess naturalIdDataAccess = naturalIdAccessMap.put(
						naturalIdAccessConfig.getNavigableRole(),
						region.getNaturalIdDataAccess( naturalIdAccessConfig.getNavigableRole() )
				);
				accesses.add( naturalIdDataAccess );
			}

			legacyNaturalIdAccessesForRegion.put( region.getName(), accesses );
		}


		// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		// Collection caching

		for ( CollectionDataCachingConfig collectionAccessConfig : regionConfig.getCollectionCaching() ) {
			final CollectionDataAccess collectionDataAccess = collectionAccessMap.put(
					collectionAccessConfig.getNavigableRole(),
					region.getCollectionDataAccess( collectionAccessConfig.getNavigableRole() )
			);

			legacySecondLevelCacheNames.add(
					StringHelper.qualifyConditionally(
							getSessionFactory().getSessionFactoryOptions().getCacheRegionPrefix(),
							region.getName()
					)
			);
		}
	}

}
 
Example #29
Source File: NoCachingRegionFactory.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public DomainDataRegion buildDomainDataRegion(
		DomainDataRegionConfig regionConfig, DomainDataRegionBuildingContext buildingContext) {
	throw new NoCacheRegionFactoryAvailableException();
}
 
Example #30
Source File: AbstractCachedDomainDataAccess.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
protected AbstractCachedDomainDataAccess(
		DomainDataRegion region,
		DomainDataStorageAccess storageAccess) {
	this.region = region;
	this.storageAccess = storageAccess;
}