Class DualSessionFactory

  • All Implemented Interfaces:
    jakarta.persistence.EntityManagerFactory, Closeable, Serializable, AutoCloseable, Referenceable, 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 Detail

      • DualSessionFactory

        public DualSessionFactory​(org.hibernate.SessionFactory primary,
                                  org.hibernate.SessionFactory reader)
    • 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 jakarta.persistence.EntityManager createEntityManager()
        Specified by:
        createEntityManager in interface jakarta.persistence.EntityManagerFactory
      • createEntityManager

        public jakarta.persistence.EntityManager createEntityManager​(Map map)
        Specified by:
        createEntityManager in interface jakarta.persistence.EntityManagerFactory
      • createEntityManager

        public jakarta.persistence.EntityManager createEntityManager​(jakarta.persistence.SynchronizationType synchronizationType)
        Specified by:
        createEntityManager in interface jakarta.persistence.EntityManagerFactory
      • createEntityManager

        public jakarta.persistence.EntityManager createEntityManager​(jakarta.persistence.SynchronizationType synchronizationType,
                                                                     Map map)
        Specified by:
        createEntityManager in interface jakarta.persistence.EntityManagerFactory
      • getCriteriaBuilder

        public jakarta.persistence.criteria.CriteriaBuilder getCriteriaBuilder()
        Specified by:
        getCriteriaBuilder in interface jakarta.persistence.EntityManagerFactory
      • getMetamodel

        public jakarta.persistence.metamodel.Metamodel getMetamodel()
        Specified by:
        getMetamodel in interface jakarta.persistence.EntityManagerFactory
      • isOpen

        public boolean isOpen()
        Specified by:
        isOpen in interface jakarta.persistence.EntityManagerFactory
      • getProperties

        public Map<String,​Object> getProperties()
        Specified by:
        getProperties in interface jakarta.persistence.EntityManagerFactory
      • getPersistenceUnitUtil

        public jakarta.persistence.PersistenceUnitUtil getPersistenceUnitUtil()
        Specified by:
        getPersistenceUnitUtil in interface jakarta.persistence.EntityManagerFactory
      • addNamedQuery

        public void addNamedQuery​(String name,
                                  jakarta.persistence.Query query)
        Specified by:
        addNamedQuery in interface jakarta.persistence.EntityManagerFactory
      • unwrap

        public <T> T unwrap​(Class<T> cls)
        Specified by:
        unwrap in interface jakarta.persistence.EntityManagerFactory
      • addNamedEntityGraph

        public <T> void addNamedEntityGraph​(String graphName,
                                            jakarta.persistence.EntityGraph<T> entityGraph)
        Specified by:
        addNamedEntityGraph in interface jakarta.persistence.EntityManagerFactory
      • findEntityGraphsByType

        public <T> List<jakarta.persistence.EntityGraph<? super T>> findEntityGraphsByType​(Class<T> entityClass)
        Specified by:
        findEntityGraphsByType in interface org.hibernate.SessionFactory
      • getSessionFactoryOptions

        public org.hibernate.boot.spi.SessionFactoryOptions getSessionFactoryOptions()
        Specified by:
        getSessionFactoryOptions in interface org.hibernate.SessionFactory
      • withOptions

        public org.hibernate.SessionBuilder withOptions()
        Specified by:
        withOptions in interface org.hibernate.SessionFactory
      • openSession

        public org.hibernate.Session openSession()
                                          throws org.hibernate.HibernateException
        Specified by:
        openSession in interface org.hibernate.SessionFactory
        Throws:
        org.hibernate.HibernateException
      • getCurrentSession

        public org.hibernate.Session getCurrentSession()
                                                throws org.hibernate.HibernateException
        Specified by:
        getCurrentSession in interface org.hibernate.SessionFactory
        Throws:
        org.hibernate.HibernateException
      • withStatelessOptions

        public org.hibernate.StatelessSessionBuilder withStatelessOptions()
        Specified by:
        withStatelessOptions in interface org.hibernate.SessionFactory
      • openStatelessSession

        public org.hibernate.StatelessSession openStatelessSession()
        Specified by:
        openStatelessSession in interface org.hibernate.SessionFactory
      • openStatelessSession

        public org.hibernate.StatelessSession openStatelessSession​(Connection connection)
        Specified by:
        openStatelessSession in interface org.hibernate.SessionFactory
      • inSession

        public void inSession​(Consumer<org.hibernate.Session> action)
        Specified by:
        inSession in interface org.hibernate.SessionFactory
      • inTransaction

        public void inTransaction​(Consumer<org.hibernate.Session> action)
        Specified by:
        inTransaction in interface org.hibernate.SessionFactory
      • fromSession

        public <R> R fromSession​(Function<org.hibernate.Session,​R> action)
        Specified by:
        fromSession in interface org.hibernate.SessionFactory
      • fromTransaction

        public <R> R fromTransaction​(Function<org.hibernate.Session,​R> action)
        Specified by:
        fromTransaction in interface org.hibernate.SessionFactory
      • getStatistics

        public org.hibernate.stat.Statistics getStatistics()
        Specified by:
        getStatistics in interface org.hibernate.SessionFactory
      • close

        public void close()
                   throws org.hibernate.HibernateException
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Specified by:
        close in interface jakarta.persistence.EntityManagerFactory
        Specified by:
        close in interface org.hibernate.SessionFactory
        Throws:
        org.hibernate.HibernateException
      • isClosed

        public boolean isClosed()
        Specified by:
        isClosed in interface org.hibernate.SessionFactory
      • getCache

        public org.hibernate.Cache getCache()
        Specified by:
        getCache in interface jakarta.persistence.EntityManagerFactory
        Specified by:
        getCache in interface org.hibernate.SessionFactory
      • getDefinedFilterNames

        public Set getDefinedFilterNames()
        Specified by:
        getDefinedFilterNames in interface org.hibernate.SessionFactory
      • getFilterDefinition

        public org.hibernate.engine.spi.FilterDefinition getFilterDefinition​(String filterName)
                                                                      throws org.hibernate.HibernateException
        Specified by:
        getFilterDefinition in interface org.hibernate.SessionFactory
        Throws:
        org.hibernate.HibernateException
      • containsFetchProfileDefinition

        public boolean containsFetchProfileDefinition​(String name)
        Specified by:
        containsFetchProfileDefinition in interface org.hibernate.SessionFactory