Package org.hibernate.cache.spi.access

Examples of org.hibernate.cache.spi.access.NaturalIdRegionAccessStrategy


          entityAccessStrategies.put( cacheRegionName, accessStrategy );
          cacheAccess.addCacheRegion( cacheRegionName, entityRegion );
        }
      }

      NaturalIdRegionAccessStrategy naturalIdAccessStrategy = null;
      if ( model.hasNaturalId() && model.getNaturalIdCacheRegionName() != null ) {
        final String naturalIdCacheRegionName = cacheRegionPrefix + model.getNaturalIdCacheRegionName();
        naturalIdAccessStrategy = ( NaturalIdRegionAccessStrategy ) entityAccessStrategies.get( naturalIdCacheRegionName );

        if ( naturalIdAccessStrategy == null && settings.isSecondLevelCacheEnabled() ) {
View Full Code Here


        event.getLockOptions(),
        event.getSession()
    );
   
    if ( stats ) {
      final NaturalIdRegionAccessStrategy naturalIdCacheAccessStrategy = event.getEntityPersister().getNaturalIdCacheAccessStrategy();
      final String regionName = naturalIdCacheAccessStrategy == null ? null : naturalIdCacheAccessStrategy.getRegion().getName();
     
      factory.getStatisticsImplementor().naturalIdQueryExecuted(
          regionName,
          System.currentTimeMillis() - startTime );
    }
View Full Code Here

        sessionCachedNaturalIdValues = cachedNaturalId.getValues();
      }
    }

    if ( persister.hasNaturalIdCache() ) {
      final NaturalIdRegionAccessStrategy naturalIdCacheAccessStrategy = persister
          .getNaturalIdCacheAccessStrategy();
      final NaturalIdCacheKey naturalIdCacheKey = new NaturalIdCacheKey( naturalIdValues, persister, session() );
      naturalIdCacheAccessStrategy.evict( naturalIdCacheKey );

      if ( sessionCachedNaturalIdValues != null
          && !Arrays.equals( sessionCachedNaturalIdValues, naturalIdValues ) ) {
        final NaturalIdCacheKey sessionNaturalIdCacheKey = new NaturalIdCacheKey( sessionCachedNaturalIdValues, persister, session() );
        naturalIdCacheAccessStrategy.evict( sessionNaturalIdCacheKey );
      }
    }

    return sessionCachedNaturalIdValues;
  }
View Full Code Here

    }

    // Try resolution from second-level cache
    final NaturalIdCacheKey naturalIdCacheKey = new NaturalIdCacheKey( naturalIdValues, persister, session() );

    final NaturalIdRegionAccessStrategy naturalIdCacheAccessStrategy = persister.getNaturalIdCacheAccessStrategy();
    pk = CacheHelper.fromSharedCache( session(), naturalIdCacheKey, naturalIdCacheAccessStrategy );

    // Found in second-level cache, store in session cache
    final SessionFactoryImplementor factory = session().getFactory();
    if ( pk != null ) {
      if ( factory.getStatistics().isStatisticsEnabled() ) {
        factory.getStatisticsImplementor().naturalIdCacheHit(
            naturalIdCacheAccessStrategy.getRegion().getName()
        );
      }

      if ( LOG.isTraceEnabled() ) {
        // protected to avoid Arrays.toString call unless needed
        LOG.tracef(
            "Found natural key [%s] -> primary key [%s] xref in second-level cache for %s",
            Arrays.toString( naturalIdValues ),
            pk,
            persister.getRootEntityName()
        );
      }

      if ( entityNaturalIdResolutionCache == null ) {
        entityNaturalIdResolutionCache = new NaturalIdResolutionCache( persister );
        NaturalIdResolutionCache existingCache = naturalIdResolutionCacheMap.putIfAbsent( persister, entityNaturalIdResolutionCache );
        if ( existingCache != null ) {
          entityNaturalIdResolutionCache = existingCache;
        }
      }

      entityNaturalIdResolutionCache.pkToNaturalIdMap.put( pk, cachedNaturalId );
      entityNaturalIdResolutionCache.naturalIdToPkMap.put( cachedNaturalId, pk );
    }
    else if ( factory.getStatistics().isStatisticsEnabled() ) {
      factory.getStatisticsImplementor().naturalIdCacheMiss( naturalIdCacheAccessStrategy.getRegion().getName() );
    }

    return pk;
  }
View Full Code Here

          entityAccessStrategies.put( cacheRegionName, accessStrategy );
          allCacheRegions.put( cacheRegionName, entityRegion );
        }
      }
     
      NaturalIdRegionAccessStrategy naturalIdAccessStrategy = null;
      if ( model.hasNaturalId() && model.getNaturalIdCacheRegionName() != null ) {
        final String naturalIdCacheRegionName = cacheRegionPrefix + model.getNaturalIdCacheRegionName();
        naturalIdAccessStrategy = ( NaturalIdRegionAccessStrategy ) entityAccessStrategies.get( naturalIdCacheRegionName );
       
        if ( naturalIdAccessStrategy == null && settings.isSecondLevelCacheEnabled() ) {
View Full Code Here

        sessionCachedNaturalIdValues = cachedNaturalId.getValues();
      }
    }

    if ( persister.hasNaturalIdCache() ) {
      final NaturalIdRegionAccessStrategy naturalIdCacheAccessStrategy = persister
          .getNaturalIdCacheAccessStrategy();
      final NaturalIdCacheKey naturalIdCacheKey = new NaturalIdCacheKey( naturalIdValues, persister, session() );
      naturalIdCacheAccessStrategy.evict( naturalIdCacheKey );

      if ( sessionCachedNaturalIdValues != null
          && !Arrays.equals( sessionCachedNaturalIdValues, naturalIdValues ) ) {
        final NaturalIdCacheKey sessionNaturalIdCacheKey = new NaturalIdCacheKey( sessionCachedNaturalIdValues, persister, session() );
        naturalIdCacheAccessStrategy.evict( sessionNaturalIdCacheKey );
      }
    }

    return sessionCachedNaturalIdValues;
  }
View Full Code Here

    }

    // Try resolution from second-level cache
    final NaturalIdCacheKey naturalIdCacheKey = new NaturalIdCacheKey( naturalIdValues, persister, session() );

    final NaturalIdRegionAccessStrategy naturalIdCacheAccessStrategy = persister.getNaturalIdCacheAccessStrategy();
    pk = CacheHelper.fromSharedCache( session(), naturalIdCacheKey, naturalIdCacheAccessStrategy );

    // Found in second-level cache, store in session cache
    final SessionFactoryImplementor factory = session().getFactory();
    if ( pk != null ) {
      if ( factory.getStatistics().isStatisticsEnabled() ) {
        factory.getStatisticsImplementor().naturalIdCacheHit(
            naturalIdCacheAccessStrategy.getRegion().getName()
        );
      }

      if ( LOG.isTraceEnabled() ) {
        // protected to avoid Arrays.toString call unless needed
        LOG.tracef(
            "Found natural key [%s] -> primary key [%s] xref in second-level cache for %s",
            Arrays.toString( naturalIdValues ),
            pk,
            persister.getRootEntityName()
        );
      }

      if ( entityNaturalIdResolutionCache == null ) {
        entityNaturalIdResolutionCache = new NaturalIdResolutionCache( persister );
        naturalIdResolutionCacheMap.put( persister, entityNaturalIdResolutionCache );
      }

      entityNaturalIdResolutionCache.pkToNaturalIdMap.put( pk, cachedNaturalId );
      entityNaturalIdResolutionCache.naturalIdToPkMap.put( cachedNaturalId, pk );
    }
    else if ( factory.getStatistics().isStatisticsEnabled() ) {
      factory.getStatisticsImplementor().naturalIdCacheMiss( naturalIdCacheAccessStrategy.getRegion().getName() );
    }

    return pk;
  }
View Full Code Here

        event.getLockOptions(),
        event.getSession()
    );
   
    if ( stats ) {
      final NaturalIdRegionAccessStrategy naturalIdCacheAccessStrategy = event.getEntityPersister().getNaturalIdCacheAccessStrategy();
      final String regionName = naturalIdCacheAccessStrategy == null ? null : naturalIdCacheAccessStrategy.getRegion().getName();
     
      factory.getStatisticsImplementor().naturalIdQueryExecuted(
          regionName,
          System.currentTimeMillis() - startTime );
    }
View Full Code Here

          entityAccessStrategies.put( cacheRegionName, accessStrategy );
          cacheAccess.addCacheRegion( cacheRegionName, entityRegion );
        }
      }
     
      NaturalIdRegionAccessStrategy naturalIdAccessStrategy = null;
      if ( model.hasNaturalId() && model.getNaturalIdCacheRegionName() != null ) {
        final String naturalIdCacheRegionName = cacheRegionPrefix + model.getNaturalIdCacheRegionName();
        naturalIdAccessStrategy = ( NaturalIdRegionAccessStrategy ) entityAccessStrategies.get( naturalIdCacheRegionName );
       
        if ( naturalIdAccessStrategy == null && settings.isSecondLevelCacheEnabled() ) {
View Full Code Here

          entityAccessStrategies.put( cacheRegionName, accessStrategy );
          cacheAccess.addCacheRegion( cacheRegionName, entityRegion );
        }
      }
     
      NaturalIdRegionAccessStrategy naturalIdAccessStrategy = null;
      if ( model.hasNaturalId() && model.getNaturalIdCacheRegionName() != null ) {
        final String naturalIdCacheRegionName = cacheRegionPrefix + model.getNaturalIdCacheRegionName();
        naturalIdAccessStrategy = ( NaturalIdRegionAccessStrategy ) entityAccessStrategies.get( naturalIdCacheRegionName );
       
        if ( naturalIdAccessStrategy == null && settings.isSecondLevelCacheEnabled() ) {
View Full Code Here

TOP

Related Classes of org.hibernate.cache.spi.access.NaturalIdRegionAccessStrategy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.