Package io.dropwizard.hibernate
Class HibernateBundle<T>
- java.lang.Object
-
- io.dropwizard.hibernate.HibernateBundle<T>
-
- All Implemented Interfaces:
ConfiguredBundle<T>,DatabaseConfiguration<T>
- Direct Known Subclasses:
HibernateBundle,ScanningHibernateBundle
public abstract class HibernateBundle<T> extends Object implements ConfiguredBundle<T>, DatabaseConfiguration<T>
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_NAMEprotected List<Class<?>>entitiesprotected booleanlazyLoadingEnabledprotected @Nullable org.hibernate.SessionFactorysessionFactoryprotected SessionFactoryFactorysessionFactoryFactory
-
Constructor Summary
Constructors Modifier Constructor Description protectedHibernateBundle(Class<?> entity, Class<?>... entities)protectedHibernateBundle(List<Class<?>> entities, SessionFactoryFactory sessionFactoryFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidconfigure(org.hibernate.cfg.Configuration configuration)protected com.fasterxml.jackson.datatype.hibernate5.jakarta.Hibernate5JakartaModulecreateHibernate5Module()Override to configure theHibernate5JakartaModule.org.hibernate.SessionFactorygetSessionFactory()voidinitialize(Bootstrap<?> bootstrap)Initializes the application bootstrap.booleanisLazyLoadingEnabled()protected Stringname()Override to configure the name of the bundle (It's used for the bundle health check and database pool metrics)protected UnitOfWorkApplicationListenerregisterUnitOfWorkListenerIfAbsent(Environment environment)voidrun(T configuration, Environment environment)Initializes the environment.voidsetLazyLoadingEnabled(boolean lazyLoadingEnabled)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.dropwizard.db.DatabaseConfiguration
getDataSourceFactory
-
-
-
-
Field Detail
-
DEFAULT_NAME
public static final String DEFAULT_NAME
- See Also:
- Constant Field Values
-
sessionFactory
protected @Nullable org.hibernate.SessionFactory sessionFactory
-
lazyLoadingEnabled
protected boolean lazyLoadingEnabled
-
sessionFactoryFactory
protected final SessionFactoryFactory sessionFactoryFactory
-
-
Constructor Detail
-
HibernateBundle
protected HibernateBundle(List<Class<?>> entities, SessionFactoryFactory sessionFactoryFactory)
-
-
Method Detail
-
initialize
public final void initialize(Bootstrap<?> bootstrap)
Description copied from interface:ConfiguredBundleInitializes the application bootstrap.- Specified by:
initializein interfaceConfiguredBundle<T>- Parameters:
bootstrap- the application bootstrap
-
createHibernate5Module
protected com.fasterxml.jackson.datatype.hibernate5.jakarta.Hibernate5JakartaModule createHibernate5Module()
Override to configure theHibernate5JakartaModule.
-
name
protected String name()
Override to configure the name of the bundle (It's used for the bundle health check and database pool metrics)
-
run
public void run(T configuration, Environment environment) throws Exception
Description copied from interface:ConfiguredBundleInitializes the environment.- Specified by:
runin interfaceConfiguredBundle<T>- Parameters:
configuration- the configuration objectenvironment- the application'sEnvironment- Throws:
Exception- if something goes wrong
-
registerUnitOfWorkListenerIfAbsent
protected UnitOfWorkApplicationListener registerUnitOfWorkListenerIfAbsent(Environment environment)
-
isLazyLoadingEnabled
public boolean isLazyLoadingEnabled()
-
setLazyLoadingEnabled
public void setLazyLoadingEnabled(boolean lazyLoadingEnabled)
-
getSessionFactory
public org.hibernate.SessionFactory getSessionFactory()
-
configure
protected void configure(org.hibernate.cfg.Configuration configuration)
-
-