本文整理汇总了Java中org.hibernate.cache.CacheException类的典型用法代码示例。如果您正苦于以下问题:Java CacheException类的具体用法?Java CacheException怎么用?Java CacheException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CacheException类属于org.hibernate.cache包,在下文中一共展示了CacheException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: afterTransactionCompletion
import org.hibernate.cache.CacheException; //导入依赖的package包/类
public void afterTransactionCompletion(boolean success) {
while ( !processes.isEmpty() ) {
try {
processes.poll().doAfterTransactionCompletion( success, session );
}
catch (CacheException ce) {
LOG.unableToReleaseCacheLock( ce );
// continue loop
}
catch (Exception e) {
throw new AssertionFailure( "Exception releasing cache locks", e );
}
}
if ( session.getFactory().getSettings().isQueryCacheEnabled() ) {
session.getFactory().getUpdateTimestampsCache().invalidate(
querySpacesToInvalidate.toArray( new String[querySpacesToInvalidate.size()] ),
session
);
}
querySpacesToInvalidate.clear();
}
示例2: beforeExecutions
import org.hibernate.cache.CacheException; //导入依赖的package包/类
@Override
public final void beforeExecutions() throws CacheException {
// we need to obtain the lock before any actions are executed, since this may be an inverse="true"
// bidirectional association and it is one of the earlier entity actions which actually updates
// the database (this action is responsible for second-level cache invalidation only)
if ( persister.hasCache() ) {
final CacheKey ck = session.generateCacheKey(
key,
persister.getKeyType(),
persister.getRole()
);
final SoftLock lock = persister.getCacheAccessStrategy().lockItem( ck, null );
// the old behavior used key as opposed to getKey()
afterTransactionProcess = new CacheCleanupProcess( key, persister, lock );
}
}
示例3: doAfterTransactionCompletion
import org.hibernate.cache.CacheException; //导入依赖的package包/类
@Override
public void doAfterTransactionCompletion(boolean success, SessionImplementor session) throws CacheException {
final EntityPersister persister = getPersister();
if ( persister.hasCache() ) {
final CacheKey ck = getSession().generateCacheKey(
getId(),
persister.getIdentifierType(),
persister.getRootEntityName()
);
if ( success && cacheEntry!=null /*!persister.isCacheInvalidationRequired()*/ ) {
final boolean put = cacheAfterUpdate( persister, ck );
if ( put && getSession().getFactory().getStatistics().isStatisticsEnabled() ) {
getSession().getFactory().getStatisticsImplementor().secondLevelCachePut( getPersister().getCacheAccessStrategy().getRegion().getName() );
}
}
else {
persister.getCacheAccessStrategy().unlockItem( ck, lock );
}
}
postCommitUpdate( success );
}
示例4: buildAccessStrategy
import org.hibernate.cache.CacheException; //导入依赖的package包/类
@Override
public EntityRegionAccessStrategy buildAccessStrategy(final AccessType accessType) throws CacheException {
if (AccessType.READ_ONLY.equals(accessType)) {
return new EntityRegionAccessStrategyAdapter(
new ReadOnlyAccessDelegate<HazelcastEntityRegion>(this, props));
}
if (AccessType.NONSTRICT_READ_WRITE.equals(accessType)) {
return new EntityRegionAccessStrategyAdapter(
new NonStrictReadWriteAccessDelegate<HazelcastEntityRegion>(this, props));
}
if (AccessType.READ_WRITE.equals(accessType)) {
return new EntityRegionAccessStrategyAdapter(
new ReadWriteAccessDelegate<HazelcastEntityRegion>(this, props));
}
throw new CacheException("AccessType \"" + accessType + "\" is not currently supported by Hazelcast.");
}
示例5: unloadInstance
import org.hibernate.cache.CacheException; //导入依赖的package包/类
@Override
public void unloadInstance() throws CacheException {
if (instance == null) {
return;
}
if (!shutDown) {
LOGGER.warning(CacheEnvironment.SHUTDOWN_ON_STOP + " property is set to 'false'. "
+ "Leaving current HazelcastInstance active! (Warning: Do not disable Hazelcast "
+ CacheEnvironment.HAZELCAST_SHUTDOWN_HOOK_ENABLED + " property!)");
return;
}
try {
instance.getLifecycleService().shutdown();
instance = null;
} catch (Exception e) {
throw new CacheException(e);
}
}
示例6: buildAccessStrategy
import org.hibernate.cache.CacheException; //导入依赖的package包/类
@Override
public CollectionRegionAccessStrategy buildAccessStrategy(final AccessType accessType) throws CacheException {
if (AccessType.READ_ONLY.equals(accessType)) {
return new CollectionRegionAccessStrategyAdapter(
new ReadOnlyAccessDelegate<HazelcastCollectionRegion>(this, props));
}
if (AccessType.NONSTRICT_READ_WRITE.equals(accessType)) {
return new CollectionRegionAccessStrategyAdapter(
new NonStrictReadWriteAccessDelegate<HazelcastCollectionRegion>(this, props));
}
if (AccessType.READ_WRITE.equals(accessType)) {
return new CollectionRegionAccessStrategyAdapter(
new ReadWriteAccessDelegate<HazelcastCollectionRegion>(this, props));
}
throw new CacheException("AccessType \"" + accessType + "\" is not currently supported by Hazelcast.");
}
示例7: testNamedClient_noInstance
import org.hibernate.cache.CacheException; //导入依赖的package包/类
@Test
public void testNamedClient_noInstance() throws Exception {
exception.expect(ServiceException.class);
exception.expectCause(allOf(isA(CacheException.class), new BaseMatcher<CacheException>() {
@Override
public boolean matches(Object item) {
return ((CacheException) item).getMessage().contains("No client with name [dev-custom] could be found.");
}
@Override
public void describeTo(Description description) {
}
}));
Properties props = new Properties();
props.setProperty(Environment.CACHE_REGION_FACTORY, HazelcastCacheRegionFactory.class.getName());
props.setProperty(CacheEnvironment.USE_NATIVE_CLIENT, "true");
props.setProperty(CacheEnvironment.NATIVE_CLIENT_INSTANCE_NAME, "dev-custom");
props.setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
Configuration configuration = new Configuration();
configuration.addProperties(props);
SessionFactory sf = configuration.buildSessionFactory();
sf.close();
}
示例8: configure
import org.hibernate.cache.CacheException; //导入依赖的package包/类
@Override
public void configure(Properties props) {
String instanceName = CacheEnvironment.getInstanceName(props);
if (!StringUtil.isNullOrEmptyAfterTrim(instanceName)) {
LOGGER.info("Using existing HazelcastInstance [" + instanceName + "].");
this.existingInstanceName = instanceName;
} else {
String configResourcePath = CacheEnvironment.getConfigFilePath(props);
if (!StringUtil.isNullOrEmptyAfterTrim(configResourcePath)) {
try {
this.config = ConfigLoader.load(configResourcePath);
} catch (IOException e) {
LOGGER.warning("IOException: " + e.getMessage());
}
if (config == null) {
throw new CacheException("Could not find configuration file: " + configResourcePath);
}
} else {
this.config = new XmlConfigBuilder().build();
}
}
this.shutDown = CacheEnvironment.shutdownOnStop(props, (instanceName == null));
}
示例9: buildCache
import org.hibernate.cache.CacheException; //导入依赖的package包/类
@Override
public Cache buildCache(String regionName, Properties properties) throws CacheException
{
if (log.isDebugEnabled())
{
log.debug("building cache for regionName=" + regionName + ", with properties: " + properties);
}
DefaultSimpleCache<Serializable, Object> cache = new DefaultSimpleCache<Serializable, Object>(defaultMaxItems, null);
Cache hibCache = new HibernateSimpleCacheAdapter(cache, regionName);
return hibCache;
}
示例10: BasicCollectionPersister
import org.hibernate.cache.CacheException; //导入依赖的package包/类
public BasicCollectionPersister(
Collection collection,
CollectionRegionAccessStrategy cacheAccessStrategy,
Configuration cfg,
SessionFactoryImplementor factory) throws MappingException, CacheException {
super( collection, cacheAccessStrategy, cfg, factory );
}
示例11: OneToManyPersister
import org.hibernate.cache.CacheException; //导入依赖的package包/类
public OneToManyPersister(
Collection collection,
CollectionRegionAccessStrategy cacheAccessStrategy,
Configuration cfg,
SessionFactoryImplementor factory) throws MappingException, CacheException {
super( collection, cacheAccessStrategy, cfg, factory );
cascadeDeleteEnabled = collection.getKey().isCascadeDeleteEnabled() &&
factory.getDialect().supportsCascadeDelete();
keyIsNullable = collection.getKey().isNullable();
keyIsUpdateable = collection.getKey().isUpdateable();
}
示例12: preInvalidate
import org.hibernate.cache.CacheException; //导入依赖的package包/类
/**
* Perform pre-invalidation.
*
*
* @param spaces The spaces to pre-invalidate
*
* @param session
* @throws CacheException Indicated problem delegating to underlying region.
*/
public void preInvalidate(Serializable[] spaces, SessionImplementor session) throws CacheException {
final boolean stats = factory != null && factory.getStatistics().isStatisticsEnabled();
final Long ts = region.nextTimestamp() + region.getTimeout();
for ( Serializable space : spaces ) {
if ( DEBUG_ENABLED ) {
LOG.debugf( "Pre-invalidating space [%s], timestamp: %s", space, ts );
}
try {
session.getEventListenerManager().cachePutStart();
//put() has nowait semantics, is this really appropriate?
//note that it needs to be async replication, never local or sync
region.put( space, ts );
}
finally {
session.getEventListenerManager().cachePutEnd();
}
if ( stats ) {
factory.getStatisticsImplementor().updateTimestampsCachePut();
}
}
}
示例13: invalidate
import org.hibernate.cache.CacheException; //导入依赖的package包/类
/**
* Perform invalidation.
*
*
* @param spaces The spaces to pre-invalidate
*
* @param session
* @throws CacheException Indicated problem delegating to underlying region.
*/
public void invalidate(Serializable[] spaces, SessionImplementor session) throws CacheException {
final boolean stats = factory != null && factory.getStatistics().isStatisticsEnabled();
final Long ts = region.nextTimestamp();
for (Serializable space : spaces) {
if ( DEBUG_ENABLED ) {
LOG.debugf( "Invalidating space [%s], timestamp: %s", space, ts );
}
try {
session.getEventListenerManager().cachePutStart();
//put() has nowait semantics, is this really appropriate?
//note that it needs to be async replication, never local or sync
region.put( space, ts );
}
finally {
session.getEventListenerManager().cachePutEnd();
}
if ( stats ) {
factory.getStatisticsImplementor().updateTimestampsCachePut();
}
}
}
示例14: isUpToDate
import org.hibernate.cache.CacheException; //导入依赖的package包/类
/**
* Perform an up-to-date check for the given set of query spaces.
*
*
* @param spaces The spaces to check
* @param timestamp The timestamp against which to check.
*
* @param session
* @return Whether all those spaces are up-to-date
*
* @throws CacheException Indicated problem delegating to underlying region.
*/
public boolean isUpToDate(Set<Serializable> spaces, Long timestamp, SessionImplementor session) throws CacheException {
final boolean stats = factory != null && factory.getStatistics().isStatisticsEnabled();
for ( Serializable space : spaces ) {
final Long lastUpdate = getLastUpdateTimestampForSpace( space, session );
if ( lastUpdate == null ) {
if ( stats ) {
factory.getStatisticsImplementor().updateTimestampsCacheMiss();
}
//the last update timestamp was lost from the cache
//(or there were no updates since startup!)
//updateTimestamps.put( space, new Long( updateTimestamps.nextTimestamp() ) );
//result = false; // safer
}
else {
if ( DEBUG_ENABLED ) {
LOG.debugf(
"[%s] last update timestamp: %s",
space,
lastUpdate + ", result set timestamp: " + timestamp
);
}
if ( stats ) {
factory.getStatisticsImplementor().updateTimestampsCacheHit();
}
if ( lastUpdate >= timestamp ) {
return false;
}
}
}
return true;
}
示例15: evict
import org.hibernate.cache.CacheException; //导入依赖的package包/类
protected final void evict() throws CacheException {
if ( persister.hasCache() ) {
final CacheKey ck = session.generateCacheKey(
key,
persister.getKeyType(),
persister.getRole()
);
persister.getCacheAccessStrategy().remove( ck );
}
}