Package org.hibernate.metamodel.binding

Examples of org.hibernate.metamodel.binding.Caching


    if ( hibernateCacheAnnotation != null ) {
      final org.hibernate.cache.spi.access.AccessType accessType = hibernateCacheAnnotation.value( "usage" ) == null
          ? getLocalBindingContext().getMappingDefaults().getCacheAccessType()
          : CacheConcurrencyStrategy.parse( hibernateCacheAnnotation.value( "usage" ).asEnum() )
          .toAccessType();
      return new Caching(
          hibernateCacheAnnotation.value( "region" ) == null
              ? getName()
              : hibernateCacheAnnotation.value( "region" ).asString(),
          accessType,
          hibernateCacheAnnotation.value( "include" ) != null
              && "all".equals( hibernateCacheAnnotation.value( "include" ).asString() )
      );
    }

    final AnnotationInstance jpaCacheableAnnotation = JandexHelper.getSingleAnnotation(
        getClassInfo(), JPADotNames.CACHEABLE
    );

    boolean cacheable = true; // true is the default
    if ( jpaCacheableAnnotation != null && jpaCacheableAnnotation.value() != null ) {
      cacheable = jpaCacheableAnnotation.value().asBoolean();
    }

    final boolean doCaching;
    switch ( getLocalBindingContext().getMetadataImplementor().getOptions().getSharedCacheMode() ) {
      case ALL: {
        doCaching = true;
        break;
      }
      case ENABLE_SELECTIVE: {
        doCaching = cacheable;
        break;
      }
      case DISABLE_SELECTIVE: {
        doCaching = jpaCacheableAnnotation == null || cacheable;
        break;
      }
      default: {
        // treat both NONE and UNSPECIFIED the same
        doCaching = false;
        break;
      }
    }

    if ( !doCaching ) {
      return null;
    }

    return new Caching(
        getName(),
        getLocalBindingContext().getMappingDefaults().getCacheAccessType(),
        true
    );
  }
View Full Code Here


    if ( hibernateCacheAnnotation != null ) {
      final org.hibernate.cache.spi.access.AccessType accessType = hibernateCacheAnnotation.value( "usage" ) == null
          ? getLocalBindingContext().getMappingDefaults().getCacheAccessType()
          : CacheConcurrencyStrategy.parse( hibernateCacheAnnotation.value( "usage" ).asEnum() )
          .toAccessType();
      return new Caching(
          hibernateCacheAnnotation.value( "region" ) == null
              ? getName()
              : hibernateCacheAnnotation.value( "region" ).asString(),
          accessType,
          hibernateCacheAnnotation.value( "include" ) != null
              && "all".equals( hibernateCacheAnnotation.value( "include" ).asString() )
      );
    }

    final AnnotationInstance jpaCacheableAnnotation = JandexHelper.getSingleAnnotation(
        getClassInfo(), JPADotNames.CACHEABLE
    );

    boolean cacheable = true; // true is the default
    if ( jpaCacheableAnnotation != null && jpaCacheableAnnotation.value() != null ) {
      cacheable = jpaCacheableAnnotation.value().asBoolean();
    }

    final boolean doCaching;
    switch ( getLocalBindingContext().getMetadataImplementor().getOptions().getSharedCacheMode() ) {
      case ALL: {
        doCaching = true;
        break;
      }
      case ENABLE_SELECTIVE: {
        doCaching = cacheable;
        break;
      }
      case DISABLE_SELECTIVE: {
        doCaching = jpaCacheableAnnotation == null || cacheable;
        break;
      }
      default: {
        // treat both NONE and UNSPECIFIED the same
        doCaching = false;
        break;
      }
    }

    if ( !doCaching ) {
      return null;
    }

    return new Caching(
        getName(),
        getLocalBindingContext().getMappingDefaults().getCacheAccessType(),
        true
    );
  }
View Full Code Here

    final String region = cache.getRegion() != null
        ? cache.getRegion()
        : StringHelper.qualify( container().getPath(), getName() );
    final AccessType accessType = Enum.valueOf( AccessType.class, cache.getUsage() );
    final boolean cacheLazyProps = !"non-lazy".equals( cache.getInclude() );
    return new Caching( region, accessType, cacheLazyProps );
  }
View Full Code Here

      return null;
    }
    final String region = cache.getRegion() != null ? cache.getRegion() : getEntityName();
    final AccessType accessType = Enum.valueOf( AccessType.class, cache.getUsage() );
    final boolean cacheLazyProps = !"non-lazy".equals( cache.getInclude() );
    return new Caching( region, accessType, cacheLazyProps );
  }
View Full Code Here

    if ( hibernateCacheAnnotation != null ) {
      final org.hibernate.cache.spi.access.AccessType accessType = hibernateCacheAnnotation.value( "usage" ) == null
          ? getLocalBindingContext().getMappingDefaults().getCacheAccessType()
          : CacheConcurrencyStrategy.parse( hibernateCacheAnnotation.value( "usage" ).asEnum() )
          .toAccessType();
      return new Caching(
          hibernateCacheAnnotation.value( "region" ) == null
              ? getName()
              : hibernateCacheAnnotation.value( "region" ).asString(),
          accessType,
          hibernateCacheAnnotation.value( "include" ) != null
              && "all".equals( hibernateCacheAnnotation.value( "include" ).asString() )
      );
    }

    final AnnotationInstance jpaCacheableAnnotation = JandexHelper.getSingleAnnotation(
        getClassInfo(), JPADotNames.CACHEABLE
    );

    boolean cacheable = true; // true is the default
    if ( jpaCacheableAnnotation != null && jpaCacheableAnnotation.value() != null ) {
      cacheable = jpaCacheableAnnotation.value().asBoolean();
    }

    final boolean doCaching;
    switch ( getLocalBindingContext().getMetadataImplementor().getOptions().getSharedCacheMode() ) {
      case ALL: {
        doCaching = true;
        break;
      }
      case ENABLE_SELECTIVE: {
        doCaching = cacheable;
        break;
      }
      case DISABLE_SELECTIVE: {
        doCaching = jpaCacheableAnnotation == null || cacheable;
        break;
      }
      default: {
        // treat both NONE and UNSPECIFIED the same
        doCaching = false;
        break;
      }
    }

    if ( !doCaching ) {
      return null;
    }

    return new Caching(
        getName(),
        getLocalBindingContext().getMappingDefaults().getCacheAccessType(),
        true
    );
  }
View Full Code Here

    }
    final String explicitRegion = cacheElement.attributeValue( "region" );
    final String region = explicitRegion != null ? explicitRegion : entityBinding.getEntity().getName();
    final String strategy = cacheElement.attributeValue( "usage" );
    final boolean cacheLazyProps = !"non-lazy".equals( cacheElement.attributeValue( "include" ) );
    entityBinding.setCaching( new Caching( region, strategy, cacheLazyProps ) );
  }
View Full Code Here

    }

    CacheConcurrencyStrategy strategy = CacheConcurrencyStrategy.valueOf(
        cacheAnnotation.value( "usage" ).asEnum()
    );
    Caching caching = new Caching( region, strategy.toAccessType(), cacheLazyProperties );
    entityBindingState.setCaching( caching );
  }
View Full Code Here

    boolean cacheable = true; // true is the default
    if ( cacheAnnotation != null && cacheAnnotation.value() != null ) {
      cacheable = cacheAnnotation.value().asBoolean();
    }

    Caching caching = null;
    switch ( meta.getOptions().getSharedCacheMode() ) {
      case ALL: {
        caching = createCachingForCacheableAnnotation( entityBindingState );
        break;
      }
View Full Code Here

  private Caching createCachingForCacheableAnnotation(EntityBindingStateImpl entityBindingState) {
    String region = entityBindingState.getEntityName();
    RegionFactory regionFactory = meta.getServiceRegistry().getService( RegionFactory.class );
    AccessType defaultAccessType = regionFactory.getDefaultAccessType();
    return new Caching( region, defaultAccessType, true );
  }
View Full Code Here

      return null;
    }
    final String region = cache.getRegion() != null ? cache.getRegion() : entityName;
    final AccessType accessType = Enum.valueOf( AccessType.class, cache.getUsage() );
    final boolean cacheLazyProps = !"non-lazy".equals( cache.getInclude() );
    return new Caching( region, accessType, cacheLazyProps );
  }
View Full Code Here

TOP

Related Classes of org.hibernate.metamodel.binding.Caching

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.