T
- the Configuration
type expected by this bundlepublic abstract class EntityManagerBundle<T extends io.dropwizard.Configuration> extends Object implements io.dropwizard.ConfiguredBundle<T>, io.dropwizard.db.DatabaseConfiguration<T>
DatabaseConfiguration.getDataSourceFactory(Configuration)
.Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_NAME |
Modifier | Constructor and Description |
---|---|
protected |
EntityManagerBundle(Class<?> entity,
Class<?>... entities) |
Modifier and Type | Method and Description |
---|---|
protected void |
configure(com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module module)
Override to configure Jackson's
Hibernate5Module . |
protected void |
configure(PersistenceUnitConfig configuration)
Override to configure the JPA persistence unit.
|
javax.persistence.EntityManagerFactory |
getEntityManagerFactory()
Returns the
EntityManagerFactory built and configured when this bundle is bootstrapped. |
javax.persistence.EntityManager |
getSharedEntityManager()
Returns the managed, thread-safe
EntityManager built and configured when this bundle is bootstrapped. |
void |
initialize(io.dropwizard.setup.Bootstrap<?> bootstrap) |
boolean |
isSerializeLazyLoadedEntitiesEnabled()
Returns a boolean value indicating whether or not serializing lazy loaded entity associations is enabled.
|
protected String |
name()
Override to configure the name of the bundle
(It's used for the bundle health check and database pool metrics)
|
void |
run(T configuration,
io.dropwizard.setup.Environment environment) |
void |
setSerializeLazyLoadedEntitiesEnabled(boolean serializeLazyLoadedEntitiesEnabled)
Enables or disables serializing lazy loaded entity associations as determined by the given value.
|
public static final String DEFAULT_NAME
public final void run(T configuration, io.dropwizard.setup.Environment environment) throws Exception
public final void initialize(io.dropwizard.setup.Bootstrap<?> bootstrap)
initialize
in interface io.dropwizard.ConfiguredBundle<T extends io.dropwizard.Configuration>
public javax.persistence.EntityManagerFactory getEntityManagerFactory()
EntityManagerFactory
built and configured when this bundle is bootstrapped. This
EntityManagerFactory can be used to create new EntityManager
instances. Each EntityManager
created from this factory will have its own persistence context, which your application must manage.configure(PersistenceUnitConfig)
public javax.persistence.EntityManager getSharedEntityManager()
EntityManager
built and configured when this bundle is bootstrapped.
This EntityManager can be safely injected into your application code, but must be used with
UnitOfWork
annotations to declaratively scope persistence context and transaction
boundaries.UnitOfWork
,
UnitOfWorkAwareProxyFactory
public boolean isSerializeLazyLoadedEntitiesEnabled()
public void setSerializeLazyLoadedEntitiesEnabled(boolean serializeLazyLoadedEntitiesEnabled)
Bootstrap
, which initializes the bundle. Once the bundle is initialized,
any changes to the lazy loading property are ignored.serializeLazyLoadedEntitiesEnabled
- the value indicating whether lazy loading is enabled or notprotected String name()
protected void configure(com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module module)
Hibernate5Module
.module
- the Hibernate5Module objectprotected void configure(PersistenceUnitConfig configuration)
configuration
- the configuration object used to tune persistence unit configurationCopyright © 2016. All rights reserved.