protected QueryResultsRegion makeQueryResultsRegion(String regionName) { // make sure there is not an existing domain-data region with that name.. final Region existing = regionsByName.get( regionName ); if ( existing != null ) { if ( !QueryResultsRegion.class.isInstance( existing ) ) { throw new IllegalStateException( "Cannot store both domain-data and query-result-data in the same region [" + regionName ); } throw new IllegalStateException( "Illegal call to create QueryResultsRegion - one already existed" ); } return regionFactory.buildQueryResultsRegion( regionName, getSessionFactory() ); }
@Override public QueryResultsCache getQueryResultsCacheStrictly(String regionName) { if ( !getSessionFactory().getSessionFactoryOptions().isQueryCacheEnabled() ) { return null; } return namedQueryResultsCacheMap.get( regionName ); }
@Override public void evictEntityData(String entityName) { evictEntityData( getSessionFactory().getMetamodel().entityPersister( entityName ) ); }
@Override public QueryResultsCache getQueryResultsCache(String regionName) throws HibernateException { if ( !getSessionFactory().getSessionFactoryOptions().isQueryCacheEnabled() ) { return null; } if ( regionName == null || regionName.equals( getDefaultQueryResultsCache().getRegion().getName() ) ) { return getDefaultQueryResultsCache(); } final QueryResultsCache existing = namedQueryResultsCacheMap.get( regionName ); if ( existing != null ) { return existing; } return makeQueryResultsRegionAccess( regionName ); }
protected void evictEntityData(EntityPersister entityDescriptor) { EntityPersister rootEntityDescriptor = entityDescriptor; if ( entityDescriptor.isInherited() && ! entityDescriptor.getEntityName().equals( entityDescriptor.getRootEntityName() ) ) { rootEntityDescriptor = getSessionFactory().getMetamodel().entityPersister( entityDescriptor.getRootEntityName() ); } evictEntityData( rootEntityDescriptor.getNavigableRole(), rootEntityDescriptor.getCacheAccessStrategy() ); }
getSessionFactory().getSessionFactoryOptions().getCacheRegionPrefix(), region.getName() getSessionFactory().getSessionFactoryOptions().getCacheRegionPrefix(), region.getName()
public EnabledCaching(SessionFactoryImplementor sessionFactory) { this.sessionFactory = sessionFactory; this.regionFactory = getSessionFactory().getSessionFactoryOptions().getServiceRegistry().getService( RegionFactory.class ); this.regionFactory.start( sessionFactory.getSessionFactoryOptions(), sessionFactory.getProperties() ); if ( getSessionFactory().getSessionFactoryOptions().isQueryCacheEnabled() ) { final TimestampsRegion timestampsRegion = regionFactory.buildTimestampsRegion( RegionFactory.DEFAULT_UPDATE_TIMESTAMPS_REGION_UNQUALIFIED_NAME, sessionFactory ); timestampsCache = sessionFactory.getSessionFactoryOptions() .getTimestampsCacheFactory() .buildTimestampsCache( this, timestampsRegion ); legacySecondLevelCacheNames.add( timestampsRegion.getName() ); final QueryResultsRegion queryResultsRegion = regionFactory.buildQueryResultsRegion( RegionFactory.DEFAULT_QUERY_RESULTS_REGION_UNQUALIFIED_NAME, sessionFactory ); regionsByName.put( queryResultsRegion.getName(), queryResultsRegion ); defaultQueryResultsCache = new QueryResultsCacheImpl( queryResultsRegion, timestampsCache ); } else { timestampsCache = new TimestampsCacheDisabledImpl(); defaultQueryResultsCache = null; } }
protected QueryResultsRegion makeQueryResultsRegion(String regionName) { // make sure there is not an existing domain-data region with that name.. final Region existing = regionsByName.get( regionName ); if ( existing != null ) { if ( !QueryResultsRegion.class.isInstance( existing ) ) { throw new IllegalStateException( "Cannot store both domain-data and query-result-data in the same region [" + regionName ); } throw new IllegalStateException( "Illegal call to create QueryResultsRegion - one already existed" ); } return regionFactory.buildQueryResultsRegion( regionName, getSessionFactory() ); }
@Override public QueryResultsCache getQueryResultsCacheStrictly(String regionName) { if ( !getSessionFactory().getSessionFactoryOptions().isQueryCacheEnabled() ) { return null; } return namedQueryResultsCacheMap.get( regionName ); }
@Override public QueryResultsCache getQueryResultsCache(String regionName) throws HibernateException { if ( !getSessionFactory().getSessionFactoryOptions().isQueryCacheEnabled() ) { return null; } if ( regionName == null || regionName.equals( getDefaultQueryResultsCache().getRegion().getName() ) ) { return getDefaultQueryResultsCache(); } final QueryResultsCache existing = namedQueryResultsCacheMap.get( regionName ); if ( existing != null ) { return existing; } return makeQueryResultsRegionAccess( regionName ); }
getSessionFactory().getSessionFactoryOptions().getCacheRegionPrefix(), region.getName() getSessionFactory().getSessionFactoryOptions().getCacheRegionPrefix(), region.getName()
public EnabledCaching(SessionFactoryImplementor sessionFactory) { this.sessionFactory = sessionFactory; this.regionFactory = getSessionFactory().getSessionFactoryOptions().getServiceRegistry().getService( RegionFactory.class ); this.regionFactory.start( sessionFactory.getSessionFactoryOptions(), sessionFactory.getProperties() ); if ( getSessionFactory().getSessionFactoryOptions().isQueryCacheEnabled() ) { final TimestampsRegion timestampsRegion = regionFactory.buildTimestampsRegion( RegionFactory.DEFAULT_UPDATE_TIMESTAMPS_REGION_UNQUALIFIED_NAME, sessionFactory ); timestampsCache = sessionFactory.getSessionFactoryOptions() .getTimestampsCacheFactory() .buildTimestampsCache( this, timestampsRegion ); legacySecondLevelCacheNames.add( timestampsRegion.getName() ); final QueryResultsRegion queryResultsRegion = regionFactory.buildQueryResultsRegion( RegionFactory.DEFAULT_QUERY_RESULTS_REGION_UNQUALIFIED_NAME, sessionFactory ); regionsByName.put( queryResultsRegion.getName(), queryResultsRegion ); defaultQueryResultsCache = new QueryResultsCacheImpl( queryResultsRegion, timestampsCache ); } else { timestampsCache = new TimestampsCacheDisabledImpl(); defaultQueryResultsCache = null; } }