Search in sources :

Example 1 with Cacheable

use of javax.persistence.Cacheable in project hibernate-orm by hibernate.

the class AnnotationBinder method determineCacheSettings.

private static Cache determineCacheSettings(XClass clazzToProcess, MetadataBuildingContext context) {
    Cache cacheAnn = clazzToProcess.getAnnotation(Cache.class);
    if (cacheAnn != null) {
        return cacheAnn;
    }
    Cacheable cacheableAnn = clazzToProcess.getAnnotation(Cacheable.class);
    SharedCacheMode mode = determineSharedCacheMode(context);
    switch(mode) {
        case ALL:
            {
                cacheAnn = buildCacheMock(clazzToProcess.getName(), context);
                break;
            }
        case ENABLE_SELECTIVE:
            {
                if (cacheableAnn != null && cacheableAnn.value()) {
                    cacheAnn = buildCacheMock(clazzToProcess.getName(), context);
                }
                break;
            }
        case DISABLE_SELECTIVE:
            {
                if (cacheableAnn == null || cacheableAnn.value()) {
                    cacheAnn = buildCacheMock(clazzToProcess.getName(), context);
                }
                break;
            }
        default:
            {
                // treat both NONE and UNSPECIFIED the same
                break;
            }
    }
    return cacheAnn;
}
Also used : Cacheable(javax.persistence.Cacheable) SharedCacheMode(javax.persistence.SharedCacheMode) Cache(org.hibernate.annotations.Cache) NaturalIdCache(org.hibernate.annotations.NaturalIdCache)

Aggregations

Cacheable (javax.persistence.Cacheable)1 SharedCacheMode (javax.persistence.SharedCacheMode)1 Cache (org.hibernate.annotations.Cache)1 NaturalIdCache (org.hibernate.annotations.NaturalIdCache)1