微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

javax.persistence.Cacheable的实例源码

项目:lams    文件JPAOverriddenAnnotationReader.java   
private Cacheable getCacheable(Element element,XMLContext.Default defaults){
    if ( element != null ) {
        String attValue = element.attributeValue( "cacheable" );
        if ( attValue != null ) {
            AnnotationDescriptor ad = new AnnotationDescriptor( Cacheable.class );
            ad.setValue( "value",Boolean.valueOf( attValue ) );
            return AnnotationFactory.create( ad );
        }
    }
    if ( defaults.canUseJavaAnnotations() ) {
        return getPhysicalAnnotation( Cacheable.class );
    }
    else {
        return null;
    }
}
项目:lams    文件AnnotationBinder.java   
private static Cache determineCacheSettings(XClass clazzToProcess,Mappings mappings) {
    Cache cacheAnn = clazzToProcess.getAnnotation( Cache.class );
    if ( cacheAnn != null ) {
        return cacheAnn;
    }

    Cacheable cacheableAnn = clazzToProcess.getAnnotation( Cacheable.class );
    SharedCacheMode mode = determineSharedCacheMode( mappings );
    switch ( mode ) {
        case ALL: {
            cacheAnn = buildCacheMock( clazzToProcess.getName(),mappings );
            break;
        }
        case ENABLE_SELECTIVE: {
            if ( cacheableAnn != null && cacheableAnn.value() ) {
                cacheAnn = buildCacheMock( clazzToProcess.getName(),mappings );
            }
            break;
        }
        case disABLE_SELECTIVE: {
            if ( cacheableAnn == null || cacheableAnn.value() ) {
                cacheAnn = buildCacheMock( clazzToProcess.getName(),mappings );
            }
            break;
        }
        default: {
            // treat both NONE and UNSPECIFIED the same
            break;
        }
    }
    return cacheAnn;
}
项目:ef-orm    文件TableMetadata.java   
protected void initByAnno(Class<?> thisType,AnnotationProvider annos) {
    // schema初始化
    Table table = annos.getAnnotation(javax.persistence.Table.class);
    if (table != null) {
        if (table.schema().length() > 0) {
            schema = MetaHolder.getMappingSchema(table.schema());// 重定向
        }
        if (table.name().length() > 0) {
            tableName = table.name();
        }
        for(javax.persistence.Index index: table.indexes()){
            this.indexes.add(IndexDef.create(index));
        }
        for(javax.persistence.UniqueConstraint unique: table.uniqueConstraints()){
            this.uniques.add(new UniqueConstraintDef(unique));
        }
    }
    if (tableName == null) {
        // 表名未指定,缺省生成
        boolean needTranslate = JefConfiguration.getBoolean(DbCfg.TABLE_NAME_TRANSLATE,false);
        if (needTranslate) {
            tableName = dbutils.upperToUnderline(thisType.getSimpleName());
        } else {
            tableName = thisType.getSimpleName();
        }
    }
    BindDataSource bindDs = annos.getAnnotation(BindDataSource.class);
    if (bindDs != null) {
        this.bindDsName = MetaHolder.getMappingSite(StringUtils.trimToNull(bindDs.value()));
    }

    Cacheable cache = annos.getAnnotation(Cacheable.class);
    this.cacheable = cache != null && cache.value();

    EasyEntity entity = annos.getAnnotation(EasyEntity.class);
    if (entity != null) {
        this.uSEOuterJoin = entity.uSEOuterJoin();
    }
}
项目:requery    文件EntityType.java   
@Override
public boolean isCacheable() {
    return annotationOf(Entity.class).map(Entity::cacheable)
        .orElse( annotationOf(Cacheable.class).map(Cacheable::value).orElse(true));
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。