Search in sources :

Example 1 with CacheNamespaceRef

use of org.apache.ibatis.annotations.CacheNamespaceRef in project mybatis-3 by mybatis.

the class MapperAnnotationBuilder method parseCacheRef.

private void parseCacheRef() {
    CacheNamespaceRef cacheDomainRef = type.getAnnotation(CacheNamespaceRef.class);
    if (cacheDomainRef != null) {
        Class<?> refType = cacheDomainRef.value();
        String refName = cacheDomainRef.name();
        if (refType == void.class && refName.isEmpty()) {
            throw new BuilderException("Should be specified either value() or name() attribute in the @CacheNamespaceRef");
        }
        if (refType != void.class && !refName.isEmpty()) {
            throw new BuilderException("Cannot use both value() and name() attribute in the @CacheNamespaceRef");
        }
        String namespace = (refType != void.class) ? refType.getName() : refName;
        assistant.useCacheRef(namespace);
    }
}
Also used : BuilderException(org.apache.ibatis.builder.BuilderException) CacheNamespaceRef(org.apache.ibatis.annotations.CacheNamespaceRef)

Aggregations

CacheNamespaceRef (org.apache.ibatis.annotations.CacheNamespaceRef)1 BuilderException (org.apache.ibatis.builder.BuilderException)1