Package io.dropwizard.hibernate.dual
Class DualSessionFactory
- java.lang.Object
-
- io.dropwizard.hibernate.dual.DualSessionFactory
-
- All Implemented Interfaces:
Closeable
,Serializable
,AutoCloseable
,Referenceable
,javax.persistence.EntityManagerFactory
,org.hibernate.jpa.HibernateEntityManagerFactory
,org.hibernate.SessionFactory
public class DualSessionFactory extends Object implements org.hibernate.SessionFactory
Represents a wrapper/decorator class for a Hibernate session factory that can manage both a primary session factory and a read-only session factory.- Since:
- 2.1
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DualSessionFactory(org.hibernate.SessionFactory primary, org.hibernate.SessionFactory reader)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> void
addNamedEntityGraph(String graphName, javax.persistence.EntityGraph<T> entityGraph)
void
addNamedQuery(String name, javax.persistence.Query query)
void
close()
boolean
containsFetchProfileDefinition(String name)
javax.persistence.EntityManager
createEntityManager()
javax.persistence.EntityManager
createEntityManager(Map map)
javax.persistence.EntityManager
createEntityManager(javax.persistence.SynchronizationType synchronizationType)
javax.persistence.EntityManager
createEntityManager(javax.persistence.SynchronizationType synchronizationType, Map map)
org.hibernate.SessionFactory
current()
<T> List<javax.persistence.EntityGraph<? super T>>
findEntityGraphsByType(Class<T> entityClass)
Map<String,org.hibernate.metadata.ClassMetadata>
getAllClassMetadata()
Map
getAllCollectionMetadata()
org.hibernate.Cache
getCache()
org.hibernate.metadata.ClassMetadata
getClassMetadata(Class entityClass)
org.hibernate.metadata.ClassMetadata
getClassMetadata(String entityName)
org.hibernate.metadata.CollectionMetadata
getCollectionMetadata(String roleName)
javax.persistence.criteria.CriteriaBuilder
getCriteriaBuilder()
org.hibernate.Session
getCurrentSession()
Set
getDefinedFilterNames()
org.hibernate.engine.spi.FilterDefinition
getFilterDefinition(String filterName)
org.hibernate.Metamodel
getMetamodel()
javax.persistence.PersistenceUnitUtil
getPersistenceUnitUtil()
Map<String,Object>
getProperties()
Reference
getReference()
org.hibernate.boot.spi.SessionFactoryOptions
getSessionFactoryOptions()
org.hibernate.stat.Statistics
getStatistics()
org.hibernate.TypeHelper
getTypeHelper()
boolean
isClosed()
boolean
isOpen()
org.hibernate.Session
openSession()
org.hibernate.StatelessSession
openStatelessSession()
org.hibernate.StatelessSession
openStatelessSession(Connection connection)
org.hibernate.SessionFactory
prepare(boolean readOnly)
Activates either the primary or the reader session factory depending on the readOnly parameter.<T> T
unwrap(Class<T> cls)
org.hibernate.SessionBuilder
withOptions()
org.hibernate.StatelessSessionBuilder
withStatelessOptions()
-
-
-
Method Detail
-
prepare
public org.hibernate.SessionFactory prepare(boolean readOnly)
Activates either the primary or the reader session factory depending on the readOnly parameter.- Parameters:
readOnly
-- Returns:
- the session factory in use
-
current
public org.hibernate.SessionFactory current()
-
createEntityManager
public javax.persistence.EntityManager createEntityManager()
- Specified by:
createEntityManager
in interfacejavax.persistence.EntityManagerFactory
-
createEntityManager
public javax.persistence.EntityManager createEntityManager(Map map)
- Specified by:
createEntityManager
in interfacejavax.persistence.EntityManagerFactory
-
createEntityManager
public javax.persistence.EntityManager createEntityManager(javax.persistence.SynchronizationType synchronizationType)
- Specified by:
createEntityManager
in interfacejavax.persistence.EntityManagerFactory
-
createEntityManager
public javax.persistence.EntityManager createEntityManager(javax.persistence.SynchronizationType synchronizationType, Map map)
- Specified by:
createEntityManager
in interfacejavax.persistence.EntityManagerFactory
-
getCriteriaBuilder
public javax.persistence.criteria.CriteriaBuilder getCriteriaBuilder()
- Specified by:
getCriteriaBuilder
in interfacejavax.persistence.EntityManagerFactory
-
isOpen
public boolean isOpen()
- Specified by:
isOpen
in interfacejavax.persistence.EntityManagerFactory
-
getProperties
public Map<String,Object> getProperties()
- Specified by:
getProperties
in interfacejavax.persistence.EntityManagerFactory
-
getPersistenceUnitUtil
public javax.persistence.PersistenceUnitUtil getPersistenceUnitUtil()
- Specified by:
getPersistenceUnitUtil
in interfacejavax.persistence.EntityManagerFactory
-
addNamedQuery
public void addNamedQuery(String name, javax.persistence.Query query)
- Specified by:
addNamedQuery
in interfacejavax.persistence.EntityManagerFactory
-
unwrap
public <T> T unwrap(Class<T> cls)
- Specified by:
unwrap
in interfacejavax.persistence.EntityManagerFactory
-
addNamedEntityGraph
public <T> void addNamedEntityGraph(String graphName, javax.persistence.EntityGraph<T> entityGraph)
- Specified by:
addNamedEntityGraph
in interfacejavax.persistence.EntityManagerFactory
-
findEntityGraphsByType
public <T> List<javax.persistence.EntityGraph<? super T>> findEntityGraphsByType(Class<T> entityClass)
- Specified by:
findEntityGraphsByType
in interfaceorg.hibernate.jpa.HibernateEntityManagerFactory
-
getMetamodel
public org.hibernate.Metamodel getMetamodel()
- Specified by:
getMetamodel
in interfacejavax.persistence.EntityManagerFactory
- Specified by:
getMetamodel
in interfaceorg.hibernate.jpa.HibernateEntityManagerFactory
-
getReference
public Reference getReference() throws NamingException
- Specified by:
getReference
in interfaceReferenceable
- Throws:
NamingException
-
getSessionFactoryOptions
public org.hibernate.boot.spi.SessionFactoryOptions getSessionFactoryOptions()
- Specified by:
getSessionFactoryOptions
in interfaceorg.hibernate.SessionFactory
-
withOptions
public org.hibernate.SessionBuilder withOptions()
- Specified by:
withOptions
in interfaceorg.hibernate.SessionFactory
-
openSession
public org.hibernate.Session openSession() throws org.hibernate.HibernateException
- Specified by:
openSession
in interfaceorg.hibernate.SessionFactory
- Throws:
org.hibernate.HibernateException
-
getCurrentSession
public org.hibernate.Session getCurrentSession() throws org.hibernate.HibernateException
- Specified by:
getCurrentSession
in interfaceorg.hibernate.SessionFactory
- Throws:
org.hibernate.HibernateException
-
withStatelessOptions
public org.hibernate.StatelessSessionBuilder withStatelessOptions()
- Specified by:
withStatelessOptions
in interfaceorg.hibernate.SessionFactory
-
openStatelessSession
public org.hibernate.StatelessSession openStatelessSession()
- Specified by:
openStatelessSession
in interfaceorg.hibernate.SessionFactory
-
openStatelessSession
public org.hibernate.StatelessSession openStatelessSession(Connection connection)
- Specified by:
openStatelessSession
in interfaceorg.hibernate.SessionFactory
-
getStatistics
public org.hibernate.stat.Statistics getStatistics()
- Specified by:
getStatistics
in interfaceorg.hibernate.SessionFactory
-
close
public void close() throws org.hibernate.HibernateException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfacejavax.persistence.EntityManagerFactory
- Specified by:
close
in interfaceorg.hibernate.SessionFactory
- Throws:
org.hibernate.HibernateException
-
isClosed
public boolean isClosed()
- Specified by:
isClosed
in interfaceorg.hibernate.SessionFactory
-
getCache
public org.hibernate.Cache getCache()
- Specified by:
getCache
in interfacejavax.persistence.EntityManagerFactory
- Specified by:
getCache
in interfaceorg.hibernate.SessionFactory
-
getDefinedFilterNames
public Set getDefinedFilterNames()
- Specified by:
getDefinedFilterNames
in interfaceorg.hibernate.SessionFactory
-
getFilterDefinition
public org.hibernate.engine.spi.FilterDefinition getFilterDefinition(String filterName) throws org.hibernate.HibernateException
- Specified by:
getFilterDefinition
in interfaceorg.hibernate.SessionFactory
- Throws:
org.hibernate.HibernateException
-
containsFetchProfileDefinition
public boolean containsFetchProfileDefinition(String name)
- Specified by:
containsFetchProfileDefinition
in interfaceorg.hibernate.SessionFactory
-
getTypeHelper
public org.hibernate.TypeHelper getTypeHelper()
- Specified by:
getTypeHelper
in interfaceorg.hibernate.SessionFactory
-
getClassMetadata
public org.hibernate.metadata.ClassMetadata getClassMetadata(Class entityClass)
- Specified by:
getClassMetadata
in interfaceorg.hibernate.SessionFactory
-
getClassMetadata
public org.hibernate.metadata.ClassMetadata getClassMetadata(String entityName)
- Specified by:
getClassMetadata
in interfaceorg.hibernate.SessionFactory
-
getCollectionMetadata
public org.hibernate.metadata.CollectionMetadata getCollectionMetadata(String roleName)
- Specified by:
getCollectionMetadata
in interfaceorg.hibernate.SessionFactory
-
getAllClassMetadata
public Map<String,org.hibernate.metadata.ClassMetadata> getAllClassMetadata()
- Specified by:
getAllClassMetadata
in interfaceorg.hibernate.SessionFactory
-
getAllCollectionMetadata
public Map getAllCollectionMetadata()
- Specified by:
getAllCollectionMetadata
in interfaceorg.hibernate.SessionFactory
-
-