Search in sources :

Example 1 with DomainDataCachingConfig

use of org.hibernate.cache.cfg.spi.DomainDataCachingConfig in project infinispan by infinispan.

the class TestSessionAccessImpl method collectionAccess.

@Override
public Object collectionAccess(InfinispanBaseRegion region, AccessType accessType) {
    DomainDataRegionImpl impl = (DomainDataRegionImpl) region;
    NavigableRole role = impl.config().getCollectionCaching().stream().filter(c -> c.getAccessType() == accessType).map(DomainDataCachingConfig::getNavigableRole).findFirst().orElseThrow(() -> new IllegalArgumentException());
    return impl.getCollectionDataAccess(role);
}
Also used : Connection(java.sql.Connection) TestSessionAccess(org.infinispan.test.hibernate.cache.commons.util.TestSessionAccess) Sync(org.infinispan.hibernate.cache.v53.impl.Sync) JdbcResourceTransactionMock(org.infinispan.test.hibernate.cache.commons.util.JdbcResourceTransactionMock) BatchModeJtaPlatform(org.infinispan.test.hibernate.cache.commons.util.BatchModeJtaPlatform) Transaction(org.hibernate.Transaction) Query(org.hibernate.query.Query) AccessType(org.hibernate.cache.spi.access.AccessType) SessionFactoryImpl(org.hibernate.internal.SessionFactoryImpl) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) Synchronization(javax.transaction.Synchronization) Collection(java.util.Collection) Collectors(java.util.stream.Collectors) JdbcResourceTransactionAccess(org.hibernate.resource.transaction.backend.jdbc.spi.JdbcResourceTransactionAccess) NavigableRole(org.hibernate.metamodel.model.domain.NavigableRole) SoftLock(org.hibernate.cache.spi.access.SoftLock) JdbcSessionOwner(org.hibernate.resource.jdbc.spi.JdbcSessionOwner) ControlledTimeService(org.infinispan.util.ControlledTimeService) List(java.util.List) CacheException(org.hibernate.cache.CacheException) TransactionImpl(org.hibernate.engine.transaction.internal.TransactionImpl) SharedSessionContractImplementor(org.hibernate.engine.spi.SharedSessionContractImplementor) Mockito.mock(org.mockito.Mockito.mock) JdbcConnectionAccess(org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess) DomainDataRegionImpl(org.infinispan.hibernate.cache.v53.impl.DomainDataRegionImpl) DomainDataCachingConfig(org.hibernate.cache.cfg.spi.DomainDataCachingConfig) TransactionCoordinator(org.hibernate.resource.transaction.spi.TransactionCoordinator) Session(org.hibernate.Session) MetaInfServices(org.kohsuke.MetaInfServices) SessionFactoryOptions(org.hibernate.boot.spi.SessionFactoryOptions) EntityDataAccess(org.hibernate.cache.spi.access.EntityDataAccess) DirectAccessRegion(org.hibernate.cache.spi.DirectAccessRegion) CachedDomainDataAccess(org.hibernate.cache.spi.access.CachedDomainDataAccess) SQLException(java.sql.SQLException) RegionFactory(org.hibernate.cache.spi.RegionFactory) TransactionCoordinatorOwner(org.hibernate.resource.transaction.spi.TransactionCoordinatorOwner) NoJtaPlatform(org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform) AbstractSharedSessionContract(org.hibernate.internal.AbstractSharedSessionContract) FlushMode(org.hibernate.FlushMode) CacheImplementor(org.hibernate.cache.spi.CacheImplementor) JtaPlatform(org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform) JdbcServices(org.hibernate.engine.jdbc.spi.JdbcServices) JdbcSessionContext(org.hibernate.resource.jdbc.spi.JdbcSessionContext) Mockito.when(org.mockito.Mockito.when) ServiceRegistry(org.hibernate.service.ServiceRegistry) InfinispanBaseRegion(org.infinispan.hibernate.cache.commons.InfinispanBaseRegion) Status(javax.transaction.Status) JdbcResourceLocalTransactionCoordinatorBuilderImpl(org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorBuilderImpl) SqlExceptionHelper(org.hibernate.engine.jdbc.spi.SqlExceptionHelper) SessionCreationOptions(org.hibernate.internal.SessionCreationOptions) JpaCompliance(org.hibernate.jpa.spi.JpaCompliance) DomainDataRegionImpl(org.infinispan.hibernate.cache.v53.impl.DomainDataRegionImpl) DomainDataCachingConfig(org.hibernate.cache.cfg.spi.DomainDataCachingConfig) NavigableRole(org.hibernate.metamodel.model.domain.NavigableRole)

Example 2 with DomainDataCachingConfig

use of org.hibernate.cache.cfg.spi.DomainDataCachingConfig in project infinispan by infinispan.

the class TestSessionAccessImpl method entityAccess.

@Override
public Object entityAccess(InfinispanBaseRegion region, AccessType accessType) {
    DomainDataRegionImpl impl = (DomainDataRegionImpl) region;
    NavigableRole role = impl.config().getEntityCaching().stream().filter(c -> c.getAccessType() == accessType).map(DomainDataCachingConfig::getNavigableRole).findFirst().orElseThrow(() -> new IllegalArgumentException());
    return impl.getEntityDataAccess(role);
}
Also used : Connection(java.sql.Connection) TestSessionAccess(org.infinispan.test.hibernate.cache.commons.util.TestSessionAccess) Sync(org.infinispan.hibernate.cache.v53.impl.Sync) JdbcResourceTransactionMock(org.infinispan.test.hibernate.cache.commons.util.JdbcResourceTransactionMock) BatchModeJtaPlatform(org.infinispan.test.hibernate.cache.commons.util.BatchModeJtaPlatform) Transaction(org.hibernate.Transaction) Query(org.hibernate.query.Query) AccessType(org.hibernate.cache.spi.access.AccessType) SessionFactoryImpl(org.hibernate.internal.SessionFactoryImpl) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) Synchronization(javax.transaction.Synchronization) Collection(java.util.Collection) Collectors(java.util.stream.Collectors) JdbcResourceTransactionAccess(org.hibernate.resource.transaction.backend.jdbc.spi.JdbcResourceTransactionAccess) NavigableRole(org.hibernate.metamodel.model.domain.NavigableRole) SoftLock(org.hibernate.cache.spi.access.SoftLock) JdbcSessionOwner(org.hibernate.resource.jdbc.spi.JdbcSessionOwner) ControlledTimeService(org.infinispan.util.ControlledTimeService) List(java.util.List) CacheException(org.hibernate.cache.CacheException) TransactionImpl(org.hibernate.engine.transaction.internal.TransactionImpl) SharedSessionContractImplementor(org.hibernate.engine.spi.SharedSessionContractImplementor) Mockito.mock(org.mockito.Mockito.mock) JdbcConnectionAccess(org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess) DomainDataRegionImpl(org.infinispan.hibernate.cache.v53.impl.DomainDataRegionImpl) DomainDataCachingConfig(org.hibernate.cache.cfg.spi.DomainDataCachingConfig) TransactionCoordinator(org.hibernate.resource.transaction.spi.TransactionCoordinator) Session(org.hibernate.Session) MetaInfServices(org.kohsuke.MetaInfServices) SessionFactoryOptions(org.hibernate.boot.spi.SessionFactoryOptions) EntityDataAccess(org.hibernate.cache.spi.access.EntityDataAccess) DirectAccessRegion(org.hibernate.cache.spi.DirectAccessRegion) CachedDomainDataAccess(org.hibernate.cache.spi.access.CachedDomainDataAccess) SQLException(java.sql.SQLException) RegionFactory(org.hibernate.cache.spi.RegionFactory) TransactionCoordinatorOwner(org.hibernate.resource.transaction.spi.TransactionCoordinatorOwner) NoJtaPlatform(org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform) AbstractSharedSessionContract(org.hibernate.internal.AbstractSharedSessionContract) FlushMode(org.hibernate.FlushMode) CacheImplementor(org.hibernate.cache.spi.CacheImplementor) JtaPlatform(org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform) JdbcServices(org.hibernate.engine.jdbc.spi.JdbcServices) JdbcSessionContext(org.hibernate.resource.jdbc.spi.JdbcSessionContext) Mockito.when(org.mockito.Mockito.when) ServiceRegistry(org.hibernate.service.ServiceRegistry) InfinispanBaseRegion(org.infinispan.hibernate.cache.commons.InfinispanBaseRegion) Status(javax.transaction.Status) JdbcResourceLocalTransactionCoordinatorBuilderImpl(org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorBuilderImpl) SqlExceptionHelper(org.hibernate.engine.jdbc.spi.SqlExceptionHelper) SessionCreationOptions(org.hibernate.internal.SessionCreationOptions) JpaCompliance(org.hibernate.jpa.spi.JpaCompliance) DomainDataRegionImpl(org.infinispan.hibernate.cache.v53.impl.DomainDataRegionImpl) DomainDataCachingConfig(org.hibernate.cache.cfg.spi.DomainDataCachingConfig) NavigableRole(org.hibernate.metamodel.model.domain.NavigableRole)

Aggregations

Connection (java.sql.Connection)2 SQLException (java.sql.SQLException)2 Collection (java.util.Collection)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Status (javax.transaction.Status)2 Synchronization (javax.transaction.Synchronization)2 FlushMode (org.hibernate.FlushMode)2 Session (org.hibernate.Session)2 Transaction (org.hibernate.Transaction)2 SessionFactoryOptions (org.hibernate.boot.spi.SessionFactoryOptions)2 CacheException (org.hibernate.cache.CacheException)2 DomainDataCachingConfig (org.hibernate.cache.cfg.spi.DomainDataCachingConfig)2 CacheImplementor (org.hibernate.cache.spi.CacheImplementor)2 DirectAccessRegion (org.hibernate.cache.spi.DirectAccessRegion)2 RegionFactory (org.hibernate.cache.spi.RegionFactory)2 AccessType (org.hibernate.cache.spi.access.AccessType)2 CachedDomainDataAccess (org.hibernate.cache.spi.access.CachedDomainDataAccess)2 EntityDataAccess (org.hibernate.cache.spi.access.EntityDataAccess)2 SoftLock (org.hibernate.cache.spi.access.SoftLock)2