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

项目:lams    文件:AnnotationBinder.java   
static void prepareDefaultCacheConcurrencyStrategy(Properties properties) {
    if ( DEFAULT_CACHE_CONCURRENCY_STRATEGY != null ) {
        LOG.trace( "Default cache concurrency strategy already defined" );
        return;
    }

    if ( !properties.containsKey( AvailableSettings.DEFAULT_CACHE_CONCURRENCY_STRATEGY ) ) {
        LOG.trace( "Given properties did not contain any default cache concurrency strategy setting" );
        return;
    }

    final String strategyName = properties.getProperty( AvailableSettings.DEFAULT_CACHE_CONCURRENCY_STRATEGY );
    LOG.tracev( "Discovered default cache concurrency strategy via config [{0}]", strategyName );
    CacheConcurrencyStrategy strategy = CacheConcurrencyStrategy.parse( strategyName );
    if ( strategy == null ) {
        LOG.trace( "Discovered default cache concurrency strategy specified nothing" );
        return;
    }

    LOG.debugf( "Setting default cache concurrency strategy via config [%s]", strategy.name() );
    DEFAULT_CACHE_CONCURRENCY_STRATEGY = strategy;
}
项目:hibernate4-memcached    文件:EntityTestUtils.java   
public static void init() {
    Map<String, Object> props = new HashMap<String, Object>();
    props.put(AvailableSettings.USE_SECOND_LEVEL_CACHE, true);
    props.put(AvailableSettings.USE_QUERY_CACHE, true);
    props.put(AvailableSettings.DEFAULT_CACHE_CONCURRENCY_STRATEGY, CacheConcurrencyStrategy.NONSTRICT_READ_WRITE);
    props.put(AvailableSettings.CACHE_REGION_FACTORY, Hibernate4MemcachedRegionFactory.class.getName());
    props.put(AvailableSettings.CACHE_REGION_PREFIX, "cachetest");
    props.put(AvailableSettings.CACHE_PROVIDER_CONFIG, "META-INF/h4m-properties.xml");
    props.put(AvailableSettings.HBM2DDL_AUTO, "create");
    props.put(AvailableSettings.USE_STRUCTURED_CACHE, "false");
    props.put(Hibernate4MemcachedRegionFactory.MEMCACHED_ADAPTER_CLASS_PROPERTY_KEY,
            SpyMemcachedAdapter.class.getName());
    props.put(SpyMemcachedAdapter.HOST_PROPERTY_KEY, "localhost:11211");
    props.put(SpyMemcachedAdapter.HASH_ALGORITHM_PROPERTY_KEY, DefaultHashAlgorithm.KETAMA_HASH.name());
    props.put(SpyMemcachedAdapter.OPERATION_TIMEOUT_MILLIS_PROPERTY_KEY, "5000");
    props.put(SpyMemcachedAdapter.TRANSCODER_PROPERTY_KEY, KryoTranscoder.class.getName());
    props.put(SpyMemcachedAdapter.CACHE_KEY_PREFIX_PROPERTY_KEY, "h4m");
    props.put(KryoTranscoder.COMPRESSION_THREASHOLD_PROPERTY_KEY, "20000");

    emf = Persistence.createEntityManagerFactory("cachetest", props);
}
项目:lams    文件:AnnotationBinder.java   
private static CacheConcurrencyStrategy determineCacheConcurrencyStrategy(Mappings mappings) {
    if ( DEFAULT_CACHE_CONCURRENCY_STRATEGY == null ) {
        final RegionFactory cacheRegionFactory = SettingsFactory.createRegionFactory(
                mappings.getConfigurationProperties(), true
        );
        DEFAULT_CACHE_CONCURRENCY_STRATEGY = CacheConcurrencyStrategy.fromAccessType( cacheRegionFactory.getDefaultAccessType() );
    }
    return DEFAULT_CACHE_CONCURRENCY_STRATEGY;
}
项目: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;
}
项目:smp_mobiliser_template    文件:MobiliserHibernateBeans.java   
@Override
   public PersistenceClass[] getPersistenceClasses() {

final List<PersistenceClass> lpc = new ArrayList<PersistenceClass>();

// First add all bean classes that needs cache concurrency mode
// read/write
lpc.addAll(PersistenceClass.createBeans(new Class[] { Blacklist.class,
    BlacklistType.class }, CacheConcurrencyStrategy.READ_WRITE));

// Some persistence class instances are updated rarely therefore use
// NONSTRICT_READ_WRITE
lpc.addAll(PersistenceClass.createBeans(new Class[] {},
    CacheConcurrencyStrategy.NONSTRICT_READ_WRITE));

// special handling for non chached collection
lpc.addAll(PersistenceClass.createBeans(new Class[] {},
    CacheConcurrencyStrategy.NONSTRICT_READ_WRITE,
    CacheConcurrencyStrategy.NONE));

lpc.addAll(PersistenceClass.createBeans(new Class[] {},
    CacheConcurrencyStrategy.NONE));

// Some persistence class instances are never updated. These can use
// the concurrency strategy READ

lpc.addAll(PersistenceClass.createBeans(new Class[] {},
    CacheConcurrencyStrategy.READ_ONLY));

// in case the superclass is already cached it is not allowed to set a
// cache concurrency strategy on any children!!
lpc.addAll(PersistenceClass.createBeans(new Class[] {}, null));

return lpc.toArray(new PersistenceClass[lpc.size()]);
   }
项目: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;
}
项目:replyit-master-3.2-final    文件:NotificationMessageDTO.java   
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "notificationMessage")
@OrderBy(clause = "section")
@Fetch(FetchMode.JOIN)
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public Set<NotificationMessageSectionDTO> getNotificationMessageSections() {
    return this.notificationMessageSections;
}
项目:lams    文件:AnnotationBinder.java   
private LocalCacheAnnotationImpl(String region, CacheConcurrencyStrategy usage) {
    this.region = region;
    this.usage = usage;
}
项目:lams    文件:AnnotationBinder.java   
public CacheConcurrencyStrategy usage() {
    return usage;
}
项目:lams    文件:EntityBinder.java   
public static String getCacheConcurrencyStrategy(CacheConcurrencyStrategy strategy) {
    org.hibernate.cache.spi.access.AccessType accessType = strategy.toAccessType();
    return accessType == null ? null : accessType.getExternalName();
}
项目:lams    文件:EntityClass.java   
private Caching determineCachingSettings() {
    final AnnotationInstance hibernateCacheAnnotation = JandexHelper.getSingleAnnotation(
            getClassInfo(), HibernateDotNames.CACHE
    );
    if ( hibernateCacheAnnotation != null ) {
        final org.hibernate.cache.spi.access.AccessType accessType = hibernateCacheAnnotation.value( "usage" ) == null
                ? getLocalBindingContext().getMappingDefaults().getCacheAccessType()
                : CacheConcurrencyStrategy.parse( hibernateCacheAnnotation.value( "usage" ).asEnum() )
                .toAccessType();
        return new Caching(
                hibernateCacheAnnotation.value( "region" ) == null
                        ? getName()
                        : hibernateCacheAnnotation.value( "region" ).asString(),
                accessType,
                hibernateCacheAnnotation.value( "include" ) != null
                        && "all".equals( hibernateCacheAnnotation.value( "include" ).asString() )
        );
    }

    final AnnotationInstance jpaCacheableAnnotation = JandexHelper.getSingleAnnotation(
            getClassInfo(), JPADotNames.CACHEABLE
    );

    boolean cacheable = true; // true is the default
    if ( jpaCacheableAnnotation != null && jpaCacheableAnnotation.value() != null ) {
        cacheable = jpaCacheableAnnotation.value().asBoolean();
    }

    final boolean doCaching;
    switch ( getLocalBindingContext().getMetadataImplementor().getOptions().getSharedCacheMode() ) {
        case ALL: {
            doCaching = true;
            break;
        }
        case ENABLE_SELECTIVE: {
            doCaching = cacheable;
            break;
        }
        case DISABLE_SELECTIVE: {
            doCaching = jpaCacheableAnnotation == null || cacheable;
            break;
        }
        default: {
            // treat both NONE and UNSPECIFIED the same
            doCaching = false;
            break;
        }
    }

    if ( !doCaching ) {
        return null;
    }

    return new Caching(
            getName(),
            getLocalBindingContext().getMappingDefaults().getCacheAccessType(),
            true
    );
}
项目:Spring-MVC-Blueprints    文件:RolePermission.java   
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "userId", nullable = false)
public Login getLogin() {
    return this.login;
}
项目:Spring-MVC-Blueprints    文件:RolePermission.java   
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "roleId", nullable = false)
public Role getRole() {
    return this.role;
}
项目:Spring-MVC-Blueprints    文件:Login.java   
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
@OneToOne(fetch = FetchType.LAZY)
@PrimaryKeyJoinColumn
public CustomerAccount getCustomerAccount() {
    return this.customerAccount;
}