Package org.hibernate.cache.spi.entry

Examples of org.hibernate.cache.spi.entry.CacheEntry


    if ( hasCache() ) {
      CacheKey cacheKey = session.generateCacheKey( id, getIdentifierType(), getEntityName() );
      Object ce = getCacheAccessStrategy().get( cacheKey, session.getTimestamp() );
      if (ce!=null) {
        CacheEntry cacheEntry = (CacheEntry) getCacheEntryStructure().destructure(ce, factory);
        if ( !cacheEntry.areLazyPropertiesUnfetched() ) {
          //note early exit here:
          return initializeLazyPropertiesFromCache( fieldName, entity, session, entry, cacheEntry );
        }
      }
    }
View Full Code Here


        final Object existingValue = existingEntry != null ? existingEntry.getValue() : null;
        final Object mergingValue = mergingEntry.getValue();
        if (existingValue != null && existingValue instanceof CacheEntry
                && mergingValue != null && mergingValue instanceof CacheEntry) {

            final CacheEntry existingCacheEntry = (CacheEntry) existingValue;
            final CacheEntry mergingCacheEntry = (CacheEntry) mergingValue;
            final Object mergingVersionObject = mergingCacheEntry.getVersion();
            final Object existingVersionObject = existingCacheEntry.getVersion();
            if (mergingVersionObject != null && existingVersionObject != null
                    && mergingVersionObject instanceof Comparable && existingVersionObject instanceof Comparable) {

                final Comparable mergingVersion = (Comparable) mergingVersionObject;
View Full Code Here

            return Logger.getLogger(name);
        }
    }

    private boolean compareVersion(Object key, Object value) {
        final CacheEntry currentEntry = (CacheEntry) value;
        try {
            return compareVersionUnderRowLock(key, value, currentEntry);
        } catch (InterruptedException e) {
            return false;
        }
View Full Code Here

    }

    private boolean compareVersionUnderRowLock(Object key, Object value, CacheEntry currentEntry) throws InterruptedException {
        if (map.tryLock(key, tryLockAndGetTimeout, TimeUnit.MILLISECONDS)) {
            try {
                final CacheEntry previousEntry = (CacheEntry) map.get(key);
                if (previousEntry == null
                        || versionComparator.compare(currentEntry.getVersion(), previousEntry.getVersion()) > 0) {
                    map.set(key, value);
                    return true;
                } else {
                    return false;
                }
View Full Code Here

    }

    final SessionFactoryImplementor factory = getSession().getFactory();

    if ( isCachePutEnabled( persister, session ) ) {
      final CacheEntry ce = persister.buildCacheEntry(
          instance,
          getState(),
          version,
          session
      );
View Full Code Here

      if ( persister.isCacheInvalidationRequired() || entry.getStatus()!= Status.MANAGED ) {
        persister.getCacheAccessStrategy().remove( ck );
      }
      else {
        //TODO: inefficient if that cache is just going to ignore the updated state!
        final CacheEntry ce = persister.buildCacheEntry( instance,state, nextVersion, getSession() );
        cacheEntry = persister.getCacheEntryStructure().structure( ce );
        final boolean put = persister.getCacheAccessStrategy().update( ck, cacheEntry, nextVersion, previousVersion );
        if ( put && factory.getStatistics().isStatisticsEnabled() ) {
          factory.getStatisticsImplementor().secondLevelCachePut( getPersister().getCacheAccessStrategy().getRegion().getName() );
        }
View Full Code Here

            MessageHelper.infoString( persister, id, session.getFactory() )
        );
      }

      final Object version = Versioning.getVersion( hydratedState, persister );
      final CacheEntry entry = persister.buildCacheEntry( entity, hydratedState, version, session );
      final CacheKey cacheKey = session.generateCacheKey( id, persister.getIdentifierType(), persister.getRootEntityName() );

      // explicit handling of caching for rows just inserted and then somehow forced to be read
      // from the database *within the same transaction*.  usually this is done by
      //     1) Session#refresh, or
View Full Code Here

    if ( hasCache() ) {
      CacheKey cacheKey = session.generateCacheKey( id, getIdentifierType(), getEntityName() );
      Object ce = getCacheAccessStrategy().get( cacheKey, session.getTimestamp() );
      if (ce!=null) {
        CacheEntry cacheEntry = (CacheEntry) getCacheEntryStructure().destructure(ce, factory);
        if ( !cacheEntry.areLazyPropertiesUnfetched() ) {
          //note early exit here:
          return initializeLazyPropertiesFromCache( fieldName, entity, session, entry, cacheEntry );
        }
      }
    }
View Full Code Here

    final SessionFactoryImplementor factory = getSession().getFactory();

    if ( isCachePutEnabled( persister, session ) ) {
     
      CacheEntry ce = new CacheEntry(
          getState(),
          persister,
          persister.hasUninitializedLazyProperties( instance ),
          version,
          session,
View Full Code Here

            MessageHelper.infoString( persister, id, session.getFactory() )
        );
      }

      Object version = Versioning.getVersion(hydratedState, persister);
      CacheEntry entry = new CacheEntry(
          hydratedState,
          persister,
          entityEntry.isLoadedWithLazyPropertiesUnfetched(),
          version,
          session,
View Full Code Here

TOP

Related Classes of org.hibernate.cache.spi.entry.CacheEntry

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.