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.Hibernate5Module
createHibernate5Module()
Override to configure theHibernate5Module
.org.hibernate.SessionFactory
getSessionFactory()
void
initialize(Bootstrap<?> 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)
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)
- Specified by:
initialize
in interfaceConfiguredBundle<T>
-
createHibernate5Module
protected com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module createHibernate5Module()
Override to configure theHibernate5Module
.
-
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
- Specified by:
run
in interfaceConfiguredBundle<T>
- Throws:
Exception
-
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)
-
-