本文整理汇总了Java中javax.persistence.Cacheable类的典型用法代码示例。如果您正苦于以下问题:Java Cacheable类的具体用法?Java Cacheable怎么用?Java Cacheable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Cacheable类属于javax.persistence包,在下文中一共展示了Cacheable类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCacheable
import javax.persistence.Cacheable; //导入依赖的package包/类
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;
}
}
示例2: determineCacheSettings
import javax.persistence.Cacheable; //导入依赖的package包/类
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;
}
示例3: initByAnno
import javax.persistence.Cacheable; //导入依赖的package包/类
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();
}
}
示例4: isCacheable
import javax.persistence.Cacheable; //导入依赖的package包/类
@Override
public boolean isCacheable() {
return annotationOf(Entity.class).map(Entity::cacheable)
.orElse( annotationOf(Cacheable.class).map(Cacheable::value).orElse(true));
}