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 String
DEFAULT_NAME
protected List<Class<?>>
entities
protected boolean
lazyLoadingEnabled
protected @Nullable org.hibernate.SessionFactory
sessionFactory
protected SessionFactoryFactory
sessionFactoryFactory
-
Constructor Summary
Constructors Modifier Constructor Description protected
HibernateBundle(Class<?> entity, Class<?>... entities)
protected
HibernateBundle(List<Class<?>> entities, SessionFactoryFactory sessionFactoryFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
configure(org.hibernate.cfg.Configuration configuration)
protected com.fasterxml.jackson.datatype.hibernate5.jakarta.Hibernate5JakartaModule
createHibernate5Module()
Override to configure theHibernate5JakartaModule
.org.hibernate.SessionFactory
getSessionFactory()
void
initialize(Bootstrap<?> bootstrap)
Initializes the application bootstrap.boolean
isLazyLoadingEnabled()
protected String
name()
Override to configure the name of the bundle (It's used for the bundle health check and database pool metrics)protected UnitOfWorkApplicationListener
registerUnitOfWorkListenerIfAbsent(Environment environment)
void
run(T configuration, Environment environment)
Initializes the environment.void
setLazyLoadingEnabled(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:ConfiguredBundle
Initializes the application bootstrap.- Specified by:
initialize
in 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:ConfiguredBundle
Initializes the environment.- Specified by:
run
in 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)
-
-