Class StatelessSessionWrapper

  • All Implemented Interfaces:
    Closeable, Serializable, AutoCloseable, org.hibernate.query.QueryProducer, org.hibernate.SharedSessionContract, org.hibernate.StatelessSession

    public class StatelessSessionWrapper
    extends AbstractQueryCache
    implements org.hibernate.StatelessSession
    Wrapper around stateless Hibernate sessions that includes a query cache. This wrapper forwards all calls to the underlying real Hibernate session.
    Since:
    2.16
    Author:
    Nicklas
    See Also:
    Serialized Form
    Last modified
    $Date: 2018-11-06 15:50:29 +0100 (ti, 06 nov 2018) $
    • Field Detail

      • session

        private final org.hibernate.StatelessSession session
    • Constructor Detail

      • StatelessSessionWrapper

        public StatelessSessionWrapper​(org.hibernate.StatelessSession session)
        Creates a new session wrapper
        Parameters:
        session - The real Hibernate session
    • Method Detail

      • getParentSession

        public org.hibernate.StatelessSession getParentSession()
        Get the underlying parent session from Hibernate.
      • cancelQuery

        public void cancelQuery()
                         throws org.hibernate.HibernateException
        Cancels the currently executing query in the same manner as Session.cancelQuery(). Since this method is not part of the StatelessSession interface this only works if the underlying parent session is the Hibernate implementation.
        Throws:
        org.hibernate.HibernateException
      • beginTransaction

        public org.hibernate.Transaction beginTransaction()
        Specified by:
        beginTransaction in interface org.hibernate.SharedSessionContract
      • close

        public void close()
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Specified by:
        close in interface org.hibernate.SharedSessionContract
        Specified by:
        close in interface org.hibernate.StatelessSession
      • connection

        @Deprecated
        public Connection connection()
        Deprecated.
        Specified by:
        connection in interface org.hibernate.StatelessSession
      • createCriteria

        @Deprecated
        public org.hibernate.Criteria createCriteria​(Class persistentClass,
                                                     String alias)
        Deprecated.
        Specified by:
        createCriteria in interface org.hibernate.SharedSessionContract
      • createCriteria

        @Deprecated
        public org.hibernate.Criteria createCriteria​(Class persistentClass)
        Deprecated.
        Specified by:
        createCriteria in interface org.hibernate.SharedSessionContract
      • createCriteria

        @Deprecated
        public org.hibernate.Criteria createCriteria​(String entityName,
                                                     String alias)
        Deprecated.
        Specified by:
        createCriteria in interface org.hibernate.SharedSessionContract
      • createCriteria

        @Deprecated
        public org.hibernate.Criteria createCriteria​(String entityName)
        Deprecated.
        Specified by:
        createCriteria in interface org.hibernate.SharedSessionContract
      • createQuery

        public org.hibernate.Query<?> createQuery​(String queryString)
                                           throws org.hibernate.HibernateException
        If the same query has been executed before, return the cached instance, otherwise create a new query from the parent session and cache it.
        Specified by:
        createQuery in interface org.hibernate.query.QueryProducer
        Throws:
        org.hibernate.HibernateException
      • createSQLQuery

        @Deprecated
        public org.hibernate.SQLQuery<?> createSQLQuery​(String queryString)
                                                 throws org.hibernate.HibernateException
        Deprecated.
        If the same query has been executed before, return the cached instance, otherwise create a new query from the parent session and cache it.
        Specified by:
        createSQLQuery in interface org.hibernate.query.QueryProducer
        Throws:
        org.hibernate.HibernateException
      • delete

        public void delete​(Object entity)
        Specified by:
        delete in interface org.hibernate.StatelessSession
      • delete

        public void delete​(String entityName,
                           Object entity)
        Specified by:
        delete in interface org.hibernate.StatelessSession
      • get

        public Object get​(Class entityClass,
                          Serializable id,
                          org.hibernate.LockMode lockMode)
        Specified by:
        get in interface org.hibernate.StatelessSession
      • get

        public Object get​(Class entityClass,
                          Serializable id)
        Specified by:
        get in interface org.hibernate.StatelessSession
      • get

        public Object get​(String entityName,
                          Serializable id,
                          org.hibernate.LockMode lockMode)
        Specified by:
        get in interface org.hibernate.StatelessSession
      • get

        public Object get​(String entityName,
                          Serializable id)
        Specified by:
        get in interface org.hibernate.StatelessSession
      • getNamedQuery

        public org.hibernate.Query<?> getNamedQuery​(String queryName)
                                             throws org.hibernate.HibernateException
        If the same query has been executed before, return the cached instance, otherwise create a new query from the parent session and cache it.
        Specified by:
        getNamedQuery in interface org.hibernate.query.QueryProducer
        Throws:
        org.hibernate.HibernateException
      • getTransaction

        public org.hibernate.Transaction getTransaction()
        Specified by:
        getTransaction in interface org.hibernate.SharedSessionContract
      • insert

        public Serializable insert​(Object entity)
        Specified by:
        insert in interface org.hibernate.StatelessSession
      • insert

        public Serializable insert​(String entityName,
                                   Object entity)
        Specified by:
        insert in interface org.hibernate.StatelessSession
      • refresh

        public void refresh​(Object entity,
                            org.hibernate.LockMode lockMode)
        Specified by:
        refresh in interface org.hibernate.StatelessSession
      • refresh

        public void refresh​(Object entity)
        Specified by:
        refresh in interface org.hibernate.StatelessSession
      • refresh

        public void refresh​(String entityName,
                            Object entity,
                            org.hibernate.LockMode lockMode)
        Specified by:
        refresh in interface org.hibernate.StatelessSession
      • refresh

        public void refresh​(String entityName,
                            Object entity)
        Specified by:
        refresh in interface org.hibernate.StatelessSession
      • update

        public void update​(Object entity)
        Specified by:
        update in interface org.hibernate.StatelessSession
      • update

        public void update​(String entityName,
                           Object entity)
        Specified by:
        update in interface org.hibernate.StatelessSession
      • getTenantIdentifier

        public String getTenantIdentifier()
        Specified by:
        getTenantIdentifier in interface org.hibernate.SharedSessionContract
      • getNamedProcedureCall

        public org.hibernate.procedure.ProcedureCall getNamedProcedureCall​(String name)
        Specified by:
        getNamedProcedureCall in interface org.hibernate.SharedSessionContract
      • createStoredProcedureCall

        public org.hibernate.procedure.ProcedureCall createStoredProcedureCall​(String name)
        Specified by:
        createStoredProcedureCall in interface org.hibernate.SharedSessionContract
      • createStoredProcedureCall

        public org.hibernate.procedure.ProcedureCall createStoredProcedureCall​(String paramString,
                                                                               Class... paramArrayOfClass)
        Specified by:
        createStoredProcedureCall in interface org.hibernate.SharedSessionContract
      • createStoredProcedureCall

        public org.hibernate.procedure.ProcedureCall createStoredProcedureCall​(String paramString,
                                                                               String... paramArrayOfString)
        Specified by:
        createStoredProcedureCall in interface org.hibernate.SharedSessionContract
      • getJdbcBatchSize

        public Integer getJdbcBatchSize()
        Specified by:
        getJdbcBatchSize in interface org.hibernate.SharedSessionContract
      • isConnected

        public boolean isConnected()
        Specified by:
        isConnected in interface org.hibernate.SharedSessionContract
      • isOpen

        public boolean isOpen()
        Specified by:
        isOpen in interface org.hibernate.SharedSessionContract
      • setJdbcBatchSize

        public void setJdbcBatchSize​(Integer batchSize)
        Specified by:
        setJdbcBatchSize in interface org.hibernate.SharedSessionContract
      • createNamedQuery

        public <R> org.hibernate.query.Query<R> createNamedQuery​(String queryName,
                                                                 Class<R> returnType)
        Specified by:
        createNamedQuery in interface org.hibernate.query.QueryProducer
      • createNamedQuery

        public org.hibernate.query.Query<?> createNamedQuery​(String queryName)
        Specified by:
        createNamedQuery in interface org.hibernate.query.QueryProducer
      • createNativeQuery

        public <R> org.hibernate.query.NativeQuery<R> createNativeQuery​(String queryString,
                                                                        Class<R> resultClass)
        Specified by:
        createNativeQuery in interface org.hibernate.query.QueryProducer
      • createNativeQuery

        public org.hibernate.query.NativeQuery<?> createNativeQuery​(String queryString,
                                                                    String resultSetMapping)
        Specified by:
        createNativeQuery in interface org.hibernate.query.QueryProducer
      • createNativeQuery

        public org.hibernate.query.NativeQuery<?> createNativeQuery​(String queryString)
        Specified by:
        createNativeQuery in interface org.hibernate.query.QueryProducer
      • createQuery

        public <R> org.hibernate.query.Query<R> createQuery​(String queryString,
                                                            Class<R> resultClass)
        Specified by:
        createQuery in interface org.hibernate.query.QueryProducer
      • getNamedNativeQuery

        public org.hibernate.query.NativeQuery<?> getNamedNativeQuery​(String queryName)
        Specified by:
        getNamedNativeQuery in interface org.hibernate.query.QueryProducer