org.hibernate.annotations.CacheConcurrencyStrategy Java Examples

The following examples show how to use org.hibernate.annotations.CacheConcurrencyStrategy. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EntityTestUtils.java    From hibernate4-memcached with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #2
Source File: Trainer.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@OneToMany
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public List<Pokemon> getPokemons() {
    return pokemons;
}
 
Example #3
Source File: EntityBinder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
private static String resolveCacheConcurrencyStrategy(CacheConcurrencyStrategy strategy) {
	final org.hibernate.cache.spi.access.AccessType accessType = strategy.toAccessType();
	return accessType == null ? null : accessType.getExternalName();
}
 
Example #4
Source File: EntityBinder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
private LocalCacheAnnotationStub(String region, CacheConcurrencyStrategy usage) {
	this.region = region;
	this.usage = usage;
}
 
Example #5
Source File: EntityBinder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public CacheConcurrencyStrategy usage() {
	return usage;
}
 
Example #6
Source File: EntityBinder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
private static CacheConcurrencyStrategy determineCacheConcurrencyStrategy(MetadataBuildingContext context) {
	return CacheConcurrencyStrategy.fromAccessType(
			context.getBuildingOptions().getImplicitCacheAccessType()
	);
}
 
Example #7
Source File: EntityBinder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public static String getCacheConcurrencyStrategy(CacheConcurrencyStrategy strategy) {
	org.hibernate.cache.spi.access.AccessType accessType = strategy.toAccessType();
	return accessType == null ? null : accessType.getExternalName();
}
 
Example #8
Source File: RolePermission.java    From Spring-MVC-Blueprints with MIT License 4 votes vote down vote up
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "userId", nullable = false)
public Login getLogin() {
	return this.login;
}
 
Example #9
Source File: RolePermission.java    From Spring-MVC-Blueprints with MIT License 4 votes vote down vote up
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "roleId", nullable = false)
public Role getRole() {
	return this.role;
}
 
Example #10
Source File: Login.java    From Spring-MVC-Blueprints with MIT License 4 votes vote down vote up
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
@OneToOne(fetch = FetchType.LAZY)
@PrimaryKeyJoinColumn
public CustomerAccount getCustomerAccount() {
	return this.customerAccount;
}
 
Example #11
Source File: User.java    From java-course-ee with MIT License 4 votes vote down vote up
@ManyToMany
@JoinTable(name = "users_roles")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public Set<Role> getRoles() {
    return roles;
}
 
Example #12
Source File: Role.java    From java-course-ee with MIT License 4 votes vote down vote up
@CollectionOfElements
@JoinTable(name = "roles_permissions")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public Set<String> getPermissions() {
    return permissions;
}