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.Dialect
DIALECT
protected static Class[]
NO_CLASSES
protected 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 void
afterTest()
protected void
applyCacheSettings(org.hibernate.boot.Metadata metadata)
protected void
applyMetadataBuilder(org.hibernate.boot.MetadataBuilder metadataBuilder)
protected void
applyMetadataSources(org.hibernate.boot.MetadataSources metadataSources)
protected void
applySettings(org.hibernate.boot.registry.StandardServiceRegistryBuilder builder)
protected void
cleanupTestData()
protected void
configure(org.hibernate.boot.SessionFactoryBuilder builder)
static void
doInHibernateSessionBuilder(Supplier<org.hibernate.SessionBuilder> sessionBuilderSupplier, TransactionUtil.HibernateTransactionConsumer function)
Execute function in a Hibernate transaction without return valueprotected Future<?>
executeAsync(Runnable callable)
protected void
executeSync(Runnable callable)
protected boolean
exportSchema()
protected <T> T
fromSession(Function<org.hibernate.engine.spi.SessionImplementor,T> action)
protected <T> T
fromTransaction(Function<org.hibernate.engine.spi.SessionImplementor,T> action)
protected Class[]
getAnnotatedClasses()
protected String
getCacheConcurrencyStrategy()
protected org.hibernate.dialect.Dialect
getDialect()
protected org.hibernate.boot.spi.MetadataImplementor
getMetadata()
protected String[]
getOrmXmlFiles()
void
injectServiceRegistryScope(ServiceRegistryScope registryScope)
void
injectSessionFactoryScope(SessionFactoryScope scope)
Callback to inject the SessionFactoryScope into the containervoid
injectTestModelScope(DomainModelScope modelScope)
protected void
inSession(Consumer<org.hibernate.engine.spi.SessionImplementor> action)
protected void
inTransaction(Consumer<org.hibernate.engine.spi.SessionImplementor> action)
protected boolean
isCleanupTestDataRequired()
protected boolean
overrideCacheStrategy()
void
prepareBootstrapRegistryBuilder(org.hibernate.boot.registry.BootstrapServiceRegistryBuilder bsrb)
org.hibernate.boot.spi.MetadataImplementor
produceModel(org.hibernate.boot.registry.StandardServiceRegistry serviceRegistry)
org.hibernate.boot.registry.StandardServiceRegistry
produceServiceRegistry(org.hibernate.boot.registry.StandardServiceRegistryBuilder ssrBuilder)
org.hibernate.engine.spi.SessionFactoryImplementor
produceSessionFactory(org.hibernate.boot.spi.MetadataImplementor model)
protected org.hibernate.engine.spi.SessionFactoryImplementor
sessionFactory()
protected void
sessionFactoryBuilt(org.hibernate.engine.spi.SessionFactoryImplementor factory)
protected SessionFactoryScope
sessionFactoryScope()
-
-
-
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:
produceServiceRegistry
in interfaceServiceRegistryProducer
-
prepareBootstrapRegistryBuilder
public void prepareBootstrapRegistryBuilder(org.hibernate.boot.registry.BootstrapServiceRegistryBuilder bsrb)
- Specified by:
prepareBootstrapRegistryBuilder
in interfaceServiceRegistryProducer
-
exportSchema
protected boolean exportSchema()
-
applySettings
protected void applySettings(org.hibernate.boot.registry.StandardServiceRegistryBuilder builder)
-
injectServiceRegistryScope
public void injectServiceRegistryScope(ServiceRegistryScope registryScope)
- Specified by:
injectServiceRegistryScope
in interfaceServiceRegistryScopeAware
-
produceModel
public org.hibernate.boot.spi.MetadataImplementor produceModel(org.hibernate.boot.registry.StandardServiceRegistry serviceRegistry)
- Specified by:
produceModel
in 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:
injectTestModelScope
in interfaceDomainModelScopeAware
-
produceSessionFactory
public org.hibernate.engine.spi.SessionFactoryImplementor produceSessionFactory(org.hibernate.boot.spi.MetadataImplementor model)
- Specified by:
produceSessionFactory
in 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:SessionFactoryScopeAware
Callback to inject the SessionFactoryScope into the container- Specified by:
injectSessionFactoryScope
in 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
-
-