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