org.hibernate.cache.spi.access.AccessType Java Examples
The following examples show how to use
org.hibernate.cache.spi.access.AccessType.
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: RedissonCollectionRegion.java From redisson with Apache License 2.0 | 6 votes |
@Override public CollectionRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException { if (accessType == AccessType.READ_ONLY) { return new ReadOnlyCollectionRegionAccessStrategy(settings, this); } if (accessType == AccessType.READ_WRITE) { return new ReadWriteCollectionRegionAccessStrategy(settings, this, mapCache); } if (accessType == AccessType.NONSTRICT_READ_WRITE) { return new NonStrictReadWriteCollectionRegionAccessStrategy(settings, this); } if (accessType == AccessType.TRANSACTIONAL) { return new TransactionalCollectionRegionAccessStrategy(settings, this); } throw new CacheException("Unsupported access strategy: " + accessType); }
Example #2
Source File: J2CacheAccessStrategyFactoryImpl.java From J2Cache with Apache License 2.0 | 6 votes |
public EntityRegionAccessStrategy createEntityRegionAccessStrategy(J2CacheEntityRegion entityRegion, AccessType accessType) { switch (accessType) { case READ_ONLY: if (entityRegion.getCacheDataDescription().isMutable()) { LOG.readOnlyCacheConfiguredForMutableEntity(entityRegion.getName()); } return new ReadOnlyJ2CacheEntityRegionAccessStrategy(entityRegion, entityRegion.getSettings()); case READ_WRITE: return new ReadWriteJ2CacheEntityRegionAccessStrategy(entityRegion, entityRegion.getSettings()); case NONSTRICT_READ_WRITE: return new NonStrictReadWriteJ2CacheEntityRegionAccessStrategy(entityRegion, entityRegion.getSettings()); case TRANSACTIONAL: return new TransactionalJ2CacheEntityRegionAccessStrategy(entityRegion, entityRegion.getJ2Cache(), entityRegion.getSettings()); default: throw new IllegalArgumentException("unrecognized access strategy type [" + accessType + "]"); } }
Example #3
Source File: J2CacheAccessStrategyFactoryImpl.java From J2Cache with Apache License 2.0 | 6 votes |
@Override public NaturalIdRegionAccessStrategy createNaturalIdRegionAccessStrategy(J2CacheNaturalIdRegion naturalIdRegion, AccessType accessType) { switch (accessType) { case READ_ONLY: if (naturalIdRegion.getCacheDataDescription().isMutable()) { LOG.readOnlyCacheConfiguredForMutableEntity(naturalIdRegion.getName()); } return new ReadOnlyJ2CacheNaturalIdRegionAccessStrategy(naturalIdRegion, naturalIdRegion.getSettings()); case READ_WRITE: return new ReadWriteJ2CacheNaturalIdRegionAccessStrategy(naturalIdRegion, naturalIdRegion.getSettings()); case NONSTRICT_READ_WRITE: return new NonStrictReadWriteJ2CacheNaturalIdRegionAccessStrategy(naturalIdRegion, naturalIdRegion.getSettings()); case TRANSACTIONAL: return new TransactionalJ2CacheNaturalIdRegionAccessStrategy(naturalIdRegion, naturalIdRegion.getJ2Cache(), naturalIdRegion.getSettings()); default: throw new IllegalArgumentException("unrecognized access strategy type [" + accessType + "]"); } }
Example #4
Source File: RedissonCollectionRegion.java From redisson with Apache License 2.0 | 6 votes |
@Override public CollectionRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException { if (accessType == AccessType.READ_ONLY) { return new ReadOnlyCollectionRegionAccessStrategy(settings, this); } if (accessType == AccessType.READ_WRITE) { return new ReadWriteCollectionRegionAccessStrategy(settings, this, mapCache); } if (accessType == AccessType.NONSTRICT_READ_WRITE) { return new NonStrictReadWriteCollectionRegionAccessStrategy(settings, this); } if (accessType == AccessType.TRANSACTIONAL) { return new TransactionalCollectionRegionAccessStrategy(settings, this); } throw new CacheException("Unsupported access strategy: " + accessType); }
Example #5
Source File: J2CacheAccessStrategyFactoryImpl.java From J2Cache with Apache License 2.0 | 6 votes |
public CollectionRegionAccessStrategy createCollectionRegionAccessStrategy(J2CacheCollectionRegion collectionRegion, AccessType accessType) { switch (accessType) { case READ_ONLY: if (collectionRegion.getCacheDataDescription().isMutable()) { LOG.readOnlyCacheConfiguredForMutableEntity(collectionRegion.getName()); } return new ReadOnlyJ2CacheCollectionRegionAccessStrategy(collectionRegion, collectionRegion.getSettings()); case READ_WRITE: return new ReadWriteJ2CacheCollectionRegionAccessStrategy(collectionRegion, collectionRegion.getSettings()); case NONSTRICT_READ_WRITE: return new NonStrictReadWriteJ2CacheCollectionRegionAccessStrategy(collectionRegion, collectionRegion.getSettings()); case TRANSACTIONAL: return new TransactionalJ2CacheCollectionRegionAccessStrategy(collectionRegion, collectionRegion.getJ2Cache(), collectionRegion.getSettings()); default: throw new IllegalArgumentException("unrecognized access strategy type [" + accessType + "]"); } }
Example #6
Source File: J2CacheAccessStrategyFactoryImpl.java From J2Cache with Apache License 2.0 | 6 votes |
public EntityRegionAccessStrategy createEntityRegionAccessStrategy(J2CacheEntityRegion entityRegion, AccessType accessType) { switch (accessType) { case READ_ONLY: if (entityRegion.getCacheDataDescription().isMutable()) { LOG.readOnlyCacheConfiguredForMutableEntity(entityRegion.getName()); } return new ReadOnlyJ2CacheEntityRegionAccessStrategy(entityRegion, entityRegion.getSettings()); case READ_WRITE: return new ReadWriteJ2CacheEntityRegionAccessStrategy(entityRegion, entityRegion.getSettings()); case NONSTRICT_READ_WRITE: return new NonStrictReadWriteJ2CacheEntityRegionAccessStrategy(entityRegion, entityRegion.getSettings()); case TRANSACTIONAL: return new TransactionalJ2CacheEntityRegionAccessStrategy(entityRegion, entityRegion.getJ2Cache(), entityRegion.getSettings()); default: throw new IllegalArgumentException("unrecognized access strategy type [" + accessType + "]"); } }
Example #7
Source File: RedissonNaturalIdRegion.java From redisson with Apache License 2.0 | 6 votes |
@Override public NaturalIdRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException { if (accessType == AccessType.READ_ONLY) { return new ReadOnlyNaturalIdRegionAccessStrategy(settings, this); } if (accessType == AccessType.READ_WRITE) { return new ReadWriteNaturalIdRegionAccessStrategy(settings, this, mapCache); } if (accessType == AccessType.NONSTRICT_READ_WRITE) { return new NonStrictReadWriteNaturalIdRegionAccessStrategy(settings, this); } if (accessType == AccessType.TRANSACTIONAL) { return new TransactionalNaturalIdRegionAccessStrategy(settings, this); } throw new CacheException("Unsupported access strategy: " + accessType); }
Example #8
Source File: EntityDataCachingConfigImpl.java From lams with GNU General Public License v2.0 | 5 votes |
public EntityDataCachingConfigImpl( NavigableRole rootEntityName, Supplier<Comparator> versionComparatorAccess, boolean isEntityMutable, AccessType accessType) { super( accessType ); this.navigableRole = rootEntityName; this.versionComparatorAccess = versionComparatorAccess; this.isEntityMutable = isEntityMutable; }
Example #9
Source File: MetadataBuilderImpl.java From lams with GNU General Public License v2.0 | 5 votes |
public MappingDefaultsImpl(StandardServiceRegistry serviceRegistry) { final ConfigurationService configService = serviceRegistry.getService( ConfigurationService.class ); this.implicitSchemaName = configService.getSetting( AvailableSettings.DEFAULT_SCHEMA, StandardConverters.STRING, null ); this.implicitCatalogName = configService.getSetting( AvailableSettings.DEFAULT_CATALOG, StandardConverters.STRING, null ); this.implicitlyQuoteIdentifiers = configService.getSetting( AvailableSettings.GLOBALLY_QUOTED_IDENTIFIERS, StandardConverters.BOOLEAN, false ); this.implicitCacheAccessType = configService.getSetting( AvailableSettings.DEFAULT_CACHE_CONCURRENCY_STRATEGY, new ConfigurationService.Converter<AccessType>() { @Override public AccessType convert(Object value) { return AccessType.fromExternalName( value.toString() ); } } ); }
Example #10
Source File: HibernateL2CacheStrategySelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @param accessType Cache access typr. * @param igniteInstanceName Name of the grid providing caches. * @return Session factory. */ private SessionFactory startHibernate(AccessType accessType, String igniteInstanceName) { Configuration cfg = hibernateConfiguration(accessType, igniteInstanceName); ServiceRegistryBuilder builder = new ServiceRegistryBuilder(); builder.applySetting("hibernate.connection.url", CONNECTION_URL); builder.applySetting("hibernate.show_sql", false); return cfg.buildSessionFactory(builder.buildServiceRegistry()); }
Example #11
Source File: IgniteDomainDataRegion.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override protected NaturalIdDataAccess generateNaturalIdAccess(NaturalIdDataCachingConfig naturalIdAccessCfg) { HibernateCacheProxy cache = stgyFactory.regionCache(getName()); AccessType accessType = naturalIdAccessCfg.getAccessType(); Ignite ignite = stgyFactory.node(); switch (accessType) { case READ_ONLY: HibernateAccessStrategyAdapter readOnlyStgy = stgyFactory.createReadOnlyStrategy(cache); return new IgniteNaturalIdDataAccess(readOnlyStgy, accessType, getRegionFactory(), this, ignite, cache); case NONSTRICT_READ_WRITE: HibernateAccessStrategyAdapter nonStrictReadWriteStgy = stgyFactory.createNonStrictReadWriteStrategy(cache); return new IgniteNaturalIdDataAccess(nonStrictReadWriteStgy, accessType, getRegionFactory(), this, ignite, cache); case READ_WRITE: HibernateAccessStrategyAdapter readWriteStgy = stgyFactory.createReadWriteStrategy(cache); return new IgniteNaturalIdDataAccess(readWriteStgy, accessType, getRegionFactory(), this, ignite, cache); case TRANSACTIONAL: HibernateAccessStrategyAdapter transactionalStgy = stgyFactory.createTransactionalStrategy(cache); return new IgniteNaturalIdDataAccess(transactionalStgy, accessType, getRegionFactory(), this, ignite, cache); default: throw new IllegalArgumentException("Unknown Hibernate access type: " + accessType); } }
Example #12
Source File: HibernateL2CacheStrategySelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @param accessType Cache access typr. * @param igniteInstanceName Name of the grid providing caches. * @return Session factory. */ private SessionFactory startHibernate(AccessType accessType, String igniteInstanceName) { StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder(); builder.applySetting("hibernate.connection.url", CONNECTION_URL); for (Map.Entry<String, String> e : HibernateL2CacheSelfTest.hibernateProperties(igniteInstanceName, accessType.name()).entrySet()) builder.applySetting(e.getKey(), e.getValue()); builder.applySetting(USE_STRUCTURED_CACHE, "true"); builder.applySetting(REGION_CACHE_PROPERTY + ENTITY1_NAME, "cache1"); builder.applySetting(REGION_CACHE_PROPERTY + ENTITY2_NAME, "cache2"); builder.applySetting(REGION_CACHE_PROPERTY + TIMESTAMP_CACHE, TIMESTAMP_CACHE); builder.applySetting(REGION_CACHE_PROPERTY + QUERY_CACHE, QUERY_CACHE); MetadataSources metadataSources = new MetadataSources(builder.build()); metadataSources.addAnnotatedClass(Entity1.class); metadataSources.addAnnotatedClass(Entity2.class); metadataSources.addAnnotatedClass(Entity3.class); metadataSources.addAnnotatedClass(Entity4.class); Metadata metadata = metadataSources.buildMetadata(); for (PersistentClass entityBinding : metadata.getEntityBindings()) { if (!entityBinding.isInherited()) ((RootClass)entityBinding).setCacheConcurrencyStrategy(accessType.getExternalName()); } return metadata.buildSessionFactory(); }
Example #13
Source File: Caching.java From lams with GNU General Public License v2.0 | 5 votes |
public void overlay(CacheRegionDefinition overrides) { if ( overrides == null ) { return; } requested = TruthValue.TRUE; accessType = AccessType.fromExternalName( overrides.getUsage() ); if ( StringHelper.isEmpty( overrides.getRegion() ) ) { region = overrides.getRegion(); } // ugh, primitive boolean cacheLazyProperties = overrides.isCacheLazy(); }
Example #14
Source File: IgniteCollectionDataAccess.java From ignite with Apache License 2.0 | 5 votes |
/** * @param stgy Access strategy implementation. * @param accessType Strategy access type. * @param regionFactory Region factory. * @param domainDataRegion Data region. * @param ignite Ignite instance. * @param cache Cache proxy. */ public IgniteCollectionDataAccess( HibernateAccessStrategyAdapter stgy, AccessType accessType, RegionFactory regionFactory, DomainDataRegion domainDataRegion, Ignite ignite, HibernateCacheProxy cache ) { super(stgy, regionFactory, domainDataRegion, ignite, cache); this.accessType = accessType; }
Example #15
Source File: HibernateL2CacheSelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** * Starts Hibernate. * * @param accessType Cache access type. * @param igniteInstanceName Ignite instance name. * @return Session factory. */ private SessionFactory startHibernate(org.hibernate.cache.spi.access.AccessType accessType, String igniteInstanceName) { StandardServiceRegistryBuilder builder = registryBuilder(); for (Map.Entry<String, String> e : hibernateProperties(igniteInstanceName, accessType.name()).entrySet()) builder.applySetting(e.getKey(), e.getValue()); // Use the same cache for Entity and Entity2. builder.applySetting(REGION_CACHE_PROPERTY + ENTITY2_NAME, ENTITY_NAME); StandardServiceRegistry srvcRegistry = builder.build(); MetadataSources metadataSources = new MetadataSources(srvcRegistry); for (Class entityClass : getAnnotatedClasses()) metadataSources.addAnnotatedClass(entityClass); Metadata metadata = metadataSources.buildMetadata(); for (PersistentClass entityBinding : metadata.getEntityBindings()) { if (!entityBinding.isInherited()) ((RootClass) entityBinding).setCacheConcurrencyStrategy(accessType.getExternalName()); } for (org.hibernate.mapping.Collection collectionBinding : metadata.getCollectionBindings()) collectionBinding.setCacheConcurrencyStrategy(accessType.getExternalName()); return metadata.buildSessionFactory(); }
Example #16
Source File: DomainDataRegionConfigImpl.java From lams with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("UnusedReturnValue") public Builder addEntityConfig(PersistentClass bootEntityDescriptor, AccessType accessType) { if ( entityConfigsByRootName == null ) { entityConfigsByRootName = new HashMap<>(); } // todo (5.3) : this is another place where having `BootstrapContext` / `TypeConfiguration` helps // would allow us to delay the attempt to resolve the comparator (usual timing issues wrt Type resolution) final NavigableRole rootEntityName = new NavigableRole( bootEntityDescriptor.getRootClass().getEntityName() ); final EntityDataCachingConfigImpl entityDataCachingConfig = entityConfigsByRootName.computeIfAbsent( rootEntityName, x -> new EntityDataCachingConfigImpl( rootEntityName, bootEntityDescriptor.isVersioned() ? (Supplier<Comparator>) () -> ( (VersionType) bootEntityDescriptor.getVersion().getType() ).getComparator() : null, bootEntityDescriptor.isMutable(), accessType ) ); if ( bootEntityDescriptor == bootEntityDescriptor.getRootClass() ) { entityDataCachingConfig.addCachedType( rootEntityName ); } else { entityDataCachingConfig.addCachedType( new NavigableRole( bootEntityDescriptor.getEntityName() ) ); } return this; }
Example #17
Source File: CollectionMemcachedRegion.java From hibernate4-memcached with Apache License 2.0 | 5 votes |
@Override public CollectionRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException { switch (accessType) { case READ_ONLY: return new ReadOnlyCollectionRegionAccessStrategy(this); case NONSTRICT_READ_WRITE: return new NonstrictReadWriteCollectionRegionAccessStrategy(this); default: throw new CacheException("Unsupported access strategy : " + accessType + "."); } }
Example #18
Source File: HibernateL2CacheSelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** * Starts Hibernate. * * @param accessType Cache access type. * @param igniteInstanceName Ignite instance name. * @return Session factory. */ private SessionFactory startHibernate(org.hibernate.cache.spi.access.AccessType accessType, String igniteInstanceName) { StandardServiceRegistryBuilder builder = registryBuilder(); for (Map.Entry<String, String> e : hibernateProperties(igniteInstanceName, accessType.name()).entrySet()) builder.applySetting(e.getKey(), e.getValue()); // Use the same cache for Entity and Entity2. builder.applySetting(REGION_CACHE_PROPERTY + ENTITY2_NAME, ENTITY_NAME); StandardServiceRegistry srvcRegistry = builder.build(); MetadataSources metadataSources = new MetadataSources(srvcRegistry); for (Class entityClass : getAnnotatedClasses()) metadataSources.addAnnotatedClass(entityClass); Metadata metadata = metadataSources.buildMetadata(); for (PersistentClass entityBinding : metadata.getEntityBindings()) { if (!entityBinding.isInherited()) ((RootClass)entityBinding).setCacheConcurrencyStrategy(accessType.getExternalName()); } for (org.hibernate.mapping.Collection collectionBinding : metadata.getCollectionBindings()) collectionBinding.setCacheConcurrencyStrategy(accessType.getExternalName() ); return metadata.buildSessionFactory(); }
Example #19
Source File: CollectionTransactionAccess.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public AccessType getAccessType() { return AccessType.TRANSACTIONAL; }
Example #20
Source File: CollectionReadWriteAccess.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public AccessType getAccessType() { return AccessType.READ_WRITE; }
Example #21
Source File: EntityReadOnlyAccess.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public AccessType getAccessType() { return AccessType.READ_ONLY; }
Example #22
Source File: EntityReadWriteAccess.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public AccessType getAccessType() { return AccessType.READ_WRITE; }
Example #23
Source File: AbstractRegionFactory.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public AccessType getDefaultAccessType() { return AccessType.READ_WRITE; }
Example #24
Source File: NaturalIdNonStrictReadWriteAccess.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public AccessType getAccessType() { return AccessType.NONSTRICT_READ_WRITE; }
Example #25
Source File: CollectionMemcachedRegionTest.java From hibernate4-memcached with Apache License 2.0 | 4 votes |
@Test public void buildAccessStrategy_AccessType_READ_WRITE() throws Exception { expectedException.expect(CacheException.class); expectedException.expectMessage(containsString(AccessType.READ_WRITE.toString())); collectionMemcachedRegion.buildAccessStrategy(AccessType.READ_WRITE); }
Example #26
Source File: HibernateL2CacheSelfTest.java From ignite with Apache License 2.0 | 4 votes |
/** * @throws Exception If failed. */ @Test public void testNaturalIdCache() throws Exception { for (AccessType accessType : accessTypes()) testNaturalIdCache(accessType); }
Example #27
Source File: HibernateL2CacheTransactionalSelfTest.java From ignite with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override protected AccessType[] accessTypes() { return new AccessType[]{AccessType.TRANSACTIONAL}; }
Example #28
Source File: HibernateEhCacheRegionFactory.java From yes-cart with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override public AccessType getDefaultAccessType() { return AccessType.READ_WRITE; }
Example #29
Source File: _HazelcastCacheRegionFactory.java From jhipster-ribbon-hystrix with GNU General Public License v3.0 | 4 votes |
public AccessType getDefaultAccessType() { return AccessType.READ_WRITE; }
Example #30
Source File: HibernateL2CacheSelfTest.java From ignite with Apache License 2.0 | 4 votes |
/** * @throws Exception If failed. */ @Test public void testCollectionCache() throws Exception { for (AccessType accessType : accessTypes()) testCollectionCache(accessType); }