Package org.hibernate.testing.orm.junit
Class BaseSessionFactoryFunctionalTest
- java.lang.Object
-
- org.hibernate.testing.orm.junit.BaseSessionFactoryFunctionalTest
-
- All Implemented Interfaces:
DomainModelProducer,DomainModelScopeAware,ServiceRegistryProducer,ServiceRegistryScopeAware,SessionFactoryProducer,SessionFactoryScopeAware
public abstract class BaseSessionFactoryFunctionalTest extends Object implements ServiceRegistryProducer, ServiceRegistryScopeAware, DomainModelProducer, DomainModelScopeAware, SessionFactoryProducer, SessionFactoryScopeAware
Template (GoF pattern) based abstract class for tests bridging the legacy approach of SessionFactory building as a test fixture
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.hibernate.dialect.DialectDIALECTprotected static Class[]NO_CLASSESprotected static String[]NO_MAPPINGS
-
Constructor Summary
Constructors Constructor Description BaseSessionFactoryFunctionalTest()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterTest()protected voidapplyCacheSettings(org.hibernate.boot.Metadata metadata)protected voidapplyMetadataBuilder(org.hibernate.boot.MetadataBuilder metadataBuilder)protected voidapplyMetadataSources(org.hibernate.boot.MetadataSources metadataSources)protected voidapplySettings(org.hibernate.boot.registry.StandardServiceRegistryBuilder builder)protected voidcleanupTestData()protected voidconfigure(org.hibernate.boot.SessionFactoryBuilder builder)static voiddoInHibernateSessionBuilder(Supplier<org.hibernate.SessionBuilder> sessionBuilderSupplier, TransactionUtil.HibernateTransactionConsumer function)Execute function in a Hibernate transaction without return valueprotected Future<?>executeAsync(Runnable callable)protected voidexecuteSync(Runnable callable)protected booleanexportSchema()protected <T> TfromSession(Function<org.hibernate.engine.spi.SessionImplementor,T> action)protected <T> TfromTransaction(Function<org.hibernate.engine.spi.SessionImplementor,T> action)protected Class[]getAnnotatedClasses()protected StringgetCacheConcurrencyStrategy()protected org.hibernate.dialect.DialectgetDialect()protected org.hibernate.boot.spi.MetadataImplementorgetMetadata()protected String[]getOrmXmlFiles()voidinjectServiceRegistryScope(ServiceRegistryScope registryScope)voidinjectSessionFactoryScope(SessionFactoryScope scope)Callback to inject the SessionFactoryScope into the containervoidinjectTestModelScope(DomainModelScope modelScope)protected voidinSession(Consumer<org.hibernate.engine.spi.SessionImplementor> action)protected voidinTransaction(Consumer<org.hibernate.engine.spi.SessionImplementor> action)protected booleanisCleanupTestDataRequired()protected booleanoverrideCacheStrategy()voidprepareBootstrapRegistryBuilder(org.hibernate.boot.registry.BootstrapServiceRegistryBuilder bsrb)org.hibernate.boot.spi.MetadataImplementorproduceModel(org.hibernate.boot.registry.StandardServiceRegistry serviceRegistry)org.hibernate.boot.registry.StandardServiceRegistryproduceServiceRegistry(org.hibernate.boot.registry.StandardServiceRegistryBuilder ssrBuilder)org.hibernate.engine.spi.SessionFactoryImplementorproduceSessionFactory(org.hibernate.boot.spi.MetadataImplementor model)protected org.hibernate.engine.spi.SessionFactoryImplementorsessionFactory()protected voidsessionFactoryBuilt(org.hibernate.engine.spi.SessionFactoryImplementor factory)protected SessionFactoryScopesessionFactoryScope()
-
-
-
Method Detail
-
sessionFactoryScope
protected SessionFactoryScope sessionFactoryScope()
-
sessionFactory
protected org.hibernate.engine.spi.SessionFactoryImplementor sessionFactory()
-
getMetadata
protected org.hibernate.boot.spi.MetadataImplementor getMetadata()
-
produceServiceRegistry
public org.hibernate.boot.registry.StandardServiceRegistry produceServiceRegistry(org.hibernate.boot.registry.StandardServiceRegistryBuilder ssrBuilder)
- Specified by:
produceServiceRegistryin interfaceServiceRegistryProducer
-
prepareBootstrapRegistryBuilder
public void prepareBootstrapRegistryBuilder(org.hibernate.boot.registry.BootstrapServiceRegistryBuilder bsrb)
- Specified by:
prepareBootstrapRegistryBuilderin interfaceServiceRegistryProducer
-
exportSchema
protected boolean exportSchema()
-
applySettings
protected void applySettings(org.hibernate.boot.registry.StandardServiceRegistryBuilder builder)
-
injectServiceRegistryScope
public void injectServiceRegistryScope(ServiceRegistryScope registryScope)
- Specified by:
injectServiceRegistryScopein interfaceServiceRegistryScopeAware
-
produceModel
public org.hibernate.boot.spi.MetadataImplementor produceModel(org.hibernate.boot.registry.StandardServiceRegistry serviceRegistry)
- Specified by:
produceModelin interfaceDomainModelProducer
-
applyCacheSettings
protected final void applyCacheSettings(org.hibernate.boot.Metadata metadata)
-
overrideCacheStrategy
protected boolean overrideCacheStrategy()
-
getCacheConcurrencyStrategy
protected String getCacheConcurrencyStrategy()
-
applyMetadataBuilder
protected void applyMetadataBuilder(org.hibernate.boot.MetadataBuilder metadataBuilder)
-
applyMetadataSources
protected void applyMetadataSources(org.hibernate.boot.MetadataSources metadataSources)
-
getAnnotatedClasses
protected Class[] getAnnotatedClasses()
-
getOrmXmlFiles
protected String[] getOrmXmlFiles()
-
injectTestModelScope
public void injectTestModelScope(DomainModelScope modelScope)
- Specified by:
injectTestModelScopein interfaceDomainModelScopeAware
-
produceSessionFactory
public org.hibernate.engine.spi.SessionFactoryImplementor produceSessionFactory(org.hibernate.boot.spi.MetadataImplementor model)
- Specified by:
produceSessionFactoryin interfaceSessionFactoryProducer
-
configure
protected void configure(org.hibernate.boot.SessionFactoryBuilder builder)
-
sessionFactoryBuilt
protected void sessionFactoryBuilt(org.hibernate.engine.spi.SessionFactoryImplementor factory)
-
injectSessionFactoryScope
public void injectSessionFactoryScope(SessionFactoryScope scope)
Description copied from interface:SessionFactoryScopeAwareCallback to inject the SessionFactoryScope into the container- Specified by:
injectSessionFactoryScopein interfaceSessionFactoryScopeAware
-
afterTest
@AfterEach public final void afterTest()
-
isCleanupTestDataRequired
protected boolean isCleanupTestDataRequired()
-
cleanupTestData
protected void cleanupTestData()
-
inTransaction
protected void inTransaction(Consumer<org.hibernate.engine.spi.SessionImplementor> action)
-
fromTransaction
protected <T> T fromTransaction(Function<org.hibernate.engine.spi.SessionImplementor,T> action)
-
inSession
protected void inSession(Consumer<org.hibernate.engine.spi.SessionImplementor> action)
-
fromSession
protected <T> T fromSession(Function<org.hibernate.engine.spi.SessionImplementor,T> action)
-
getDialect
protected org.hibernate.dialect.Dialect getDialect()
-
executeSync
protected void executeSync(Runnable callable)
-
doInHibernateSessionBuilder
public static void doInHibernateSessionBuilder(Supplier<org.hibernate.SessionBuilder> sessionBuilderSupplier, TransactionUtil.HibernateTransactionConsumer function)
Execute function in a Hibernate transaction without return value- Parameters:
sessionBuilderSupplier- SessionFactory supplierfunction- function
-
-