Java 类org.hibernate.annotations.Cache 实例源码

项目:lams    文件:EntityBinder.java   
public void setCache(Cache cacheAnn) {
    if ( cacheAnn != null ) {
        cacheRegion = BinderHelper.isEmptyAnnotationValue( cacheAnn.region() ) ?
                null :
                cacheAnn.region();
        cacheConcurrentStrategy = getCacheConcurrencyStrategy( cacheAnn.usage() );
        if ( "all".equalsIgnoreCase( cacheAnn.include() ) ) {
            cacheLazyProperty = true;
        }
        else if ( "non-lazy".equalsIgnoreCase( cacheAnn.include() ) ) {
            cacheLazyProperty = false;
        }
        else {
            throw new AnnotationException( "Unknown lazy property annotations: " + cacheAnn.include() );
        }
    }
    else {
        cacheConcurrentStrategy = null;
        cacheRegion = null;
        cacheLazyProperty = true;
    }
}
项目:metaworks_framework    文件:HydrationScanner.java   
public AnnotationVisitor visitAnnotation(String arg0, boolean arg1) {
    Type annotationType = Type.getType(arg0);
    switch(stage) {
    case CLASSSTAGE: {
        if (annotationType.getClassName().equals(Cache.class.getName())){
            annotation = Cache.class.getName();
        }
        break;
    }
    case FIELDSTAGE: {
        if (annotationType.getClassName().equals(Id.class.getName())){
            idMutators.put(fieldName, retrieveMutators());
        }
        if (annotationType.getClassName().equals(Hydrated.class.getName())){
            annotation = Hydrated.class.getName();
        }
        break;
    }
    default : {
        annotation = null;
        fieldName = null;
        break;
    }
    }
    return this;
}
项目:metaworks_framework    文件:HydratedSetup.java   
private static String getInheritanceHierarchyRoot(Class<?> myEntityClass) {
    String myEntityName = myEntityClass.getName();
    if (inheritanceHierarchyRoots.containsKey(myEntityName)) {
        return inheritanceHierarchyRoots.get(myEntityName);
    }
    Class<?> currentClass = myEntityClass;
    boolean eof = false;
    while (!eof) {
        Class<?> superclass = currentClass.getSuperclass();
        if (superclass.equals(Object.class) || !superclass.isAnnotationPresent(Entity.class)) {
            eof = true;
        } else {
            currentClass = superclass;
        }
    }

    if (!currentClass.isAnnotationPresent(Cache.class)) {
        currentClass = myEntityClass;
    }

    inheritanceHierarchyRoots.put(myEntityName, currentClass.getName());
    return inheritanceHierarchyRoots.get(myEntityName);
}
项目:SparkCommerce    文件:HydrationScanner.java   
public AnnotationVisitor visitAnnotation(String arg0, boolean arg1) {
    Type annotationType = Type.getType(arg0);
    switch(stage) {
    case CLASSSTAGE: {
        if (annotationType.getClassName().equals(Cache.class.getName())){
            annotation = Cache.class.getName();
        }
        break;
    }
    case FIELDSTAGE: {
        if (annotationType.getClassName().equals(Id.class.getName())){
            idMutators.put(fieldName, retrieveMutators());
        }
        if (annotationType.getClassName().equals(Hydrated.class.getName())){
            annotation = Hydrated.class.getName();
        }
        break;
    }
    default : {
        annotation = null;
        fieldName = null;
        break;
    }
    }
    return this;
}
项目:SparkCommerce    文件:HydratedSetup.java   
private static String getInheritanceHierarchyRoot(Class<?> myEntityClass) {
    String myEntityName = myEntityClass.getName();
    if (inheritanceHierarchyRoots.containsKey(myEntityName)) {
        return inheritanceHierarchyRoots.get(myEntityName);
    }
    Class<?> currentClass = myEntityClass;
    boolean eof = false;
    while (!eof) {
        Class<?> superclass = currentClass.getSuperclass();
        if (superclass.equals(Object.class) || !superclass.isAnnotationPresent(Entity.class)) {
            eof = true;
        } else {
            currentClass = superclass;
        }
    }

    if (!currentClass.isAnnotationPresent(Cache.class)) {
        currentClass = myEntityClass;
    }

    inheritanceHierarchyRoots.put(myEntityName, currentClass.getName());
    return inheritanceHierarchyRoots.get(myEntityName);
}
项目:blcdemo    文件:HydrationScanner.java   
public AnnotationVisitor visitAnnotation(String arg0, boolean arg1) {
    Type annotationType = Type.getType(arg0);
    switch(stage) {
    case CLASSSTAGE: {
        if (annotationType.getClassName().equals(Cache.class.getName())){
            annotation = Cache.class.getName();
        }
        break;
    }
    case FIELDSTAGE: {
        if (annotationType.getClassName().equals(Id.class.getName())){
            idMutators.put(fieldName, retrieveMutators());
        }
        if (annotationType.getClassName().equals(Hydrated.class.getName())){
            annotation = Hydrated.class.getName();
        }
        break;
    }
    default : {
        annotation = null;
        fieldName = null;
        break;
    }
    }
    return this;
}
项目:blcdemo    文件:HydrationScanner.java   
public void visit(String arg0, Object arg1) {
    if (Cache.class.getName().equals(annotation) && "region".equals(arg0)) {
        cacheRegion = (String) arg1;
    }
    if (Hydrated.class.getName().equals(annotation) && "factoryMethod".equals(arg0)) {
        HydrationItemDescriptor itemDescriptor = new HydrationItemDescriptor();
        itemDescriptor.setFactoryMethod((String) arg1);
        itemDescriptor.setMutators(retrieveMutators());
        cacheMutators.put(fieldName, itemDescriptor);
    }
}
项目:blcdemo    文件:HydratedSetup.java   
private static String getInheritanceHierarchyRoot(Class<?> myEntityClass) {
    String myEntityName = myEntityClass.getName();
    if (inheritanceHierarchyRoots.containsKey(myEntityName)) {
        return inheritanceHierarchyRoots.get(myEntityName);
    }
    Class<?> currentClass = myEntityClass;
    boolean eof = false;
    while (!eof) {
        Class<?> superclass = currentClass.getSuperclass();
        if (superclass.equals(Object.class) || !superclass.isAnnotationPresent(Entity.class)) {
            eof = true;
        } else {
            currentClass = superclass;
        }
    }

    if (!currentClass.isAnnotationPresent(Cache.class)) {
        currentClass = myEntityClass;
    }

    inheritanceHierarchyRoots.put(myEntityName, currentClass.getName());
    return inheritanceHierarchyRoots.get(myEntityName);
}
项目: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;
}
项目:lams    文件:CollectionBinder.java   
public void setCache(Cache cacheAnn) {
    if ( cacheAnn != null ) {
        cacheRegionName = BinderHelper.isEmptyAnnotationValue( cacheAnn.region() ) ? null : cacheAnn.region();
        cacheConcurrencyStrategy = EntityBinder.getCacheConcurrencyStrategy( cacheAnn.usage() );
    }
    else {
        cacheConcurrencyStrategy = null;
        cacheRegionName = null;
    }
}
项目:SpringBBS    文件:AcctUser.java   
@ManyToMany
@JoinTable(name = "user_badge", joinColumns = { @JoinColumn(name = "user_id") }, inverseJoinColumns = { @JoinColumn(name = "badge_id") })
@Fetch(FetchMode.SUBSELECT)
@OrderBy("id")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public Set<Badge> getBadges() {
    return badges;
}
项目:SpringBBS    文件:AcctUser.java   
@ManyToMany
//�м����,��������Ĭ����������
@JoinTable(name = "ACCT_USER_ROLE", joinColumns = { @JoinColumn(name = "USER_ID") }, inverseJoinColumns = { @JoinColumn(name = "ROLE_ID") })
//Fecth���Զ���
@Fetch(FetchMode.SUBSELECT)
//���ϰ�id����.
@OrderBy("id")
//�����ж���id�Ļ���.
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public List<AcctRole> getRoleList() {
    return roleList;
}
项目:metaworks_framework    文件:HydrationScanner.java   
public void visit(String arg0, Object arg1) {
    if (Cache.class.getName().equals(annotation) && "region".equals(arg0)) {
        cacheRegion = (String) arg1;
    }
    if (Hydrated.class.getName().equals(annotation) && "factoryMethod".equals(arg0)) {
        HydrationItemDescriptor itemDescriptor = new HydrationItemDescriptor();
        itemDescriptor.setFactoryMethod((String) arg1);
        itemDescriptor.setMutators(retrieveMutators());
        cacheMutators.put(fieldName, itemDescriptor);
    }
}
项目:SparkCommerce    文件:HydrationScanner.java   
public void visit(String arg0, Object arg1) {
    if (Cache.class.getName().equals(annotation) && "region".equals(arg0)) {
        cacheRegion = (String) arg1;
    }
    if (Hydrated.class.getName().equals(annotation) && "factoryMethod".equals(arg0)) {
        HydrationItemDescriptor itemDescriptor = new HydrationItemDescriptor();
        itemDescriptor.setFactoryMethod((String) arg1);
        itemDescriptor.setMutators(retrieveMutators());
        cacheMutators.put(fieldName, itemDescriptor);
    }
}
项目:gisgraphy    文件:AlternateOsmName.java   
/**
    * The GisFeature, the Alternate name refers to
    * 
    * @return the GisFeature, the AlternateName refers to
    */
   @ManyToOne(fetch = FetchType.LAZY)
   @JoinColumn(nullable = false, name = "street")
   @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
   @Index(name = "Alternatenameosmnameindex")
   public OpenStreetMap getStreet() {
return street;
   }
项目:gisgraphy    文件:Adm.java   
/**
    * Return the Adms of a directly higher Level in the adm the tree structure
    * @return The Adms of a directly higher Level <br>
    * <b>Example</b> Returns the Adm(s) with level 2 if the current
    *         Adm has a level equals to 1
    */
   @OneToMany(cascade = { CascadeType.ALL }, mappedBy = "parent")
   @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
   @Fetch(FetchMode.SELECT)
   public List<Adm> getChildren() {
return children;
   }
项目:gisgraphy    文件:Adm.java   
/**
    * Returns The parent Adm in the Adm tree structure
    * 
    * @return The parent Adm (with lower Level)
    */
   @ManyToOne(fetch = FetchType.EAGER)
   @JoinColumn(nullable = true, name = "parent")
   @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
   @Index(name = "admadmindex")
   public Adm getParent() {
return parent;
   }
项目:gisgraphy    文件:OpenStreetMap.java   
/**
 * @return A list of the {@link AlternateName}s for this street
 */
@OneToMany(cascade = { CascadeType.ALL }, mappedBy = "street")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Fetch(FetchMode.SELECT)
public List<AlternateOsmName> getAlternateNames() {
    return alternateNames;
}
项目:gisgraphy    文件:OpenStreetMap.java   
/**
 * @return the houseNumbers associated to that street
 */
@OneToMany(cascade = { CascadeType.ALL }, mappedBy = "street")
   @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
   @Fetch(FetchMode.SELECT)
@Sort(comparator=HouseNumberComparator.class,type=SortType.COMPARATOR)
public SortedSet<HouseNumber> getHouseNumbers() {
    return houseNumbers;
}
项目:gisgraphy    文件:ZipCode.java   
/**
    * @return the gisFeature associated to this zip code
    */
   @ManyToOne(fetch = FetchType.LAZY)
   @JoinColumn(nullable = true, name = "gisFeature")
   @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
   @Index(name = "zipcodefeatureidindex")
   public GisFeature getGisFeature() {
return this.gisFeature;
   }
项目:gisgraphy    文件:HouseNumber.java   
/**
 * @return the street associated to this house number
 */
 @ManyToOne(fetch = FetchType.LAZY)//TODO HN
 @JoinColumn(nullable = false, name = "street")
 @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
 @Index(name = "housenumberstreetindex")
public OpenStreetMap getStreet() {
    return street;
}
项目:gisgraphy    文件:GisFeature.java   
/**
    * @return The Adm with the higher Level that this GisFeature is linked to
    *         (the deeper in the Adm tree). See Important Notes for admXcode
    *         for {@link GisFeature}
    */
   @ManyToOne(fetch = FetchType.LAZY)
   @JoinColumn(name = "adm", unique = false, referencedColumnName = "id", nullable = true)
   @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
   @Index(name = "gisfeatureadmindex")
   public Adm getAdm() {
return adm;
   }
项目:gisgraphy    文件:GisFeature.java   
/**
    * @return A list of the {@link AlternateName}s for this GisFeature
    */
   @OneToMany(cascade = { CascadeType.ALL }, mappedBy = "gisFeature")
   @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
   @Fetch(FetchMode.SELECT)
   public Set<AlternateName> getAlternateNames() {
return alternateNames;
   }
项目:gisgraphy    文件:GisFeature.java   
/**
    * @return the zip codes for the city
    */
@OneToMany(cascade = { CascadeType.ALL }, mappedBy = "gisFeature")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Fetch(FetchMode.SELECT)
//TODO tests zip
public Set<ZipCode> getZipCodes() {
    return zipCodes;
}
项目:gisgraphy    文件:AlternateName.java   
/**
    * The GisFeature, the Alternate name refers to
    * 
    * @return the GisFeature, the AlternateName refers to
    */
   @ManyToOne(fetch = FetchType.LAZY)
   @JoinColumn(nullable = false, name = "gisFeature")
   @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
   @Index(name = "AlternatenameGisFeatureindex")
   public GisFeature getGisFeature() {
return gisFeature;
   }
项目:Project-H-Backend    文件:HaqChart.java   
/**
 * @return questions
 */
@ManyToMany(fetch = FetchType.LAZY)
   @JoinTable(name = "haq_chart_question",
      joinColumns = { @JoinColumn(name = "haq_chart_id") }, 
      inverseJoinColumns = { @JoinColumn(name = "question_id") })
   @ForeignKey(name="fk_haqchq_haq_chart_id", inverseName="fk_haqchq_haq_question_id")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public List<Question> getQuestions() {
    return this.questions;
}
项目:Project-H-Backend    文件:QuestionType.java   
/**
 * @return answers all possible answers of a question of given type
 */
@OneToMany(fetch = FetchType.LAZY, mappedBy = "questionType", cascade=CascadeType.ALL, orphanRemoval=true)
@IndexColumn(name = "sort_order")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public List<Answer> getAnswers() {
    return this.answers;
}
项目:Project-H-Backend    文件:Message.java   
/**
 * @return Sender - owner of a message
 */
@ManyToOne(fetch = FetchType.LAZY, optional=false)
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@JoinColumn(name = "sender_user_id", nullable = false, insertable=true, updatable=false)
@ForeignKey(name="fk_message_sender_user_id")
public User getSender() {
    return this.sender;
}
项目:Project-H-Backend    文件:Message.java   
/**
 * @return Receiver - user who receives a message
 */
@ManyToOne(fetch = FetchType.LAZY, optional=false)
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@JoinColumn(name = "receiver_user_id", nullable = false, insertable=true, updatable=false)
@ForeignKey(name="fk_message_receiver_user_id")
public User getReceiver() {
    return this.receiver;
}
项目:Project-H-Backend    文件:Message.java   
/**
 * @return inReplyToMessage
 */
@ManyToOne(fetch = FetchType.LAZY, optional=true)
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@JoinColumn(name = "in_reply_to_message_id", nullable = true, insertable=true, updatable=false)
@ForeignKey(name="fk_message_in_reply_to_message_id")
public Message getInReplyToMessage() {
    return this.inReplyToMessage;
}
项目:Project-H-Backend    文件:User.java   
/**
 * @return userAccount
 */
@OneToOne(fetch = FetchType.LAZY, optional=true)
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@JoinColumn(name = "user_account_id", nullable = true)
public UserAccount getUserAccount() {
    return this.userAccount;
}
项目:Project-H-Backend    文件:User.java   
@ManyToMany(fetch = FetchType.LAZY)
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@JoinTable(name = "user_disease", 
        joinColumns = { 
            @JoinColumn(name = "user_id") 
        }, 
        inverseJoinColumns = { 
            @JoinColumn(name = "disease_id") 
            }
)
public List<Disease> getDiseases() {
    return this.diseases;
}
项目:Project-H-Backend    文件:User.java   
/**
 * @return User's country of living
 */
@ManyToOne(fetch = FetchType.LAZY)
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@JoinColumn(name = "country_of_living_id", nullable = true)
@ForeignKey(name="fk_user_country_of_living_id")
public Country getCountry() {
    return this.country;
}
项目:Project-H-Backend    文件:User.java   
/**
 * @return User's nationality
 */
@ManyToOne(fetch = FetchType.LAZY)
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@JoinColumn(name = "nationality_id", nullable = true)
@ForeignKey(name="fk_user_nationality_id")
public Country getNationality() {
    return this.nationality;
}
项目:Project-H-Backend    文件:User.java   
/**
 * @return User's race
 */
@ManyToOne(fetch = FetchType.LAZY)
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@JoinColumn(name = "race_id", nullable = true)
@ForeignKey(name="fk_user_race_id")
public Race getRace() {
    return this.race;
}
项目:Project-H-Backend    文件:User.java   
/**
 * @return User's education
 */
@ManyToOne(fetch = FetchType.LAZY)
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@JoinColumn(name = "education_id", nullable = true)
@ForeignKey(name="fk_user_education_id")
public Education getEducation() {
    return this.education;
}
项目:Project-H-Backend    文件:User.java   
/**
 * @return User's weight in time
 */
@ElementCollection
@CollectionTable(name = "user_weight", joinColumns = @JoinColumn(name = "user_id"))
@OrderBy("date")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public List<UserWeight> getWeights() {
    return this.weights;
}
项目:Project-H-Backend    文件:Haq.java   
/**
 * @return questions
 */
@OneToMany(fetch = FetchType.LAZY, mappedBy = "haq", cascade=CascadeType.ALL, orphanRemoval=true)
@OrderBy("sortOrder")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public List<com.mobileman.projecth.domain.questionary.Question> getQuestions() {
    return this.questions;
}
项目:appengine    文件:User.java   
@ManyToMany
@JoinTable(name = "ss_user_role", joinColumns = { @JoinColumn(name = "user_id") }, inverseJoinColumns = { @JoinColumn(name = "role_id") })
// Fecth策略定义
@Fetch(FetchMode.SUBSELECT)
// 集合按id排序
@OrderBy("id ASC")
// 缓存策略
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public List<Role> getRoleList() {
    return roleList;
}