Interface SharedSessionContractImplementor

    • Method Detail

      • getPersistenceContext

        PersistenceContext getPersistenceContext()
        Get the persistence context for this session. See also getPersistenceContextInternal() for an alternative. This method is not extremely fast: if you need to access the PersistenceContext multiple times, prefer keeping a reference to it over invoking this method multiple times.
      • getSessionIdentifier

        UUID getSessionIdentifier()
        A UUID associated with each Session. Useful mainly for logging.
        Returns:
        The UUID
      • isClosed

        boolean isClosed()
        Checks whether the session is closed. Provided separately from SharedSessionContract.isOpen() as this method does not attempt any JTA synchronization registration, whereas SharedSessionContract.isOpen() does; which makes this one nicer to use for most internal purposes.
        Returns:
        true if the session is closed; false otherwise.
      • isOpenOrWaitingForAutoClose

        default boolean isOpenOrWaitingForAutoClose()
        Checks whether the session is open or is waiting for auto-close
        Returns:
        true if the session is closed or if it's waiting for auto-close; false otherwise.
      • checkOpen

        default void checkOpen()
        Performs a check whether the Session is open, and if not:
        • marks current transaction (if one) for rollback only
        • throws an IllegalStateException (JPA defines the exception type)
      • checkOpen

        void checkOpen​(boolean markForRollbackIfClosed)
        Performs a check whether the Session is open, and if not:
        • if markForRollbackIfClosed is true, marks current transaction (if one) for rollback only
        • throws an IllegalStateException (JPA defines the exception type)
      • markForRollbackOnly

        void markForRollbackOnly()
        Marks current transaction (if one) for rollback only
      • getTransactionStartTimestamp

        long getTransactionStartTimestamp()
        A "timestamp" at or before the start of the current transaction.
      • getCacheTransactionSynchronization

        CacheTransactionSynchronization getCacheTransactionSynchronization()
        The current CacheTransactionContext associated with the Session. This may return null when the Session is not currently part of a transaction.
      • isTransactionInProgress

        boolean isTransactionInProgress()
        Does this Session have an active Hibernate transaction or is there a JTA transaction in progress?
      • checkTransactionNeededForUpdateOperation

        default void checkTransactionNeededForUpdateOperation​(String exceptionMessage)
        Check if an active Transaction is necessary for the update operation to be executed. If an active Transaction is necessary but it is not then a TransactionRequiredException is raised.
        Parameters:
        exceptionMessage - the message to use for the TransactionRequiredException
      • accessTransaction

        Transaction accessTransaction()
        Provides access to the underlying transaction or creates a new transaction if one does not already exist or is active. This is primarily for internal or integrator use.
        Returns:
        the transaction
      • generateEntityKey

        EntityKey generateEntityKey​(Serializable id,
                                    EntityPersister persister)
        Hide the changing requirements of entity key creation
        Parameters:
        id - The entity id
        persister - The entity persister
        Returns:
        The entity key
      • getInterceptor

        Interceptor getInterceptor()
        Retrieves the interceptor currently in use by this event source.
        Returns:
        The interceptor.
      • setAutoClear

        void setAutoClear​(boolean enabled)
        Enable/disable automatic cache clearing from after transaction completion (for EJB3)
      • internalLoad

        Object internalLoad​(String entityName,
                            Serializable id,
                            boolean eager,
                            boolean nullable)
                     throws HibernateException
        Load an instance without checking if it was deleted.

        When nullable is disabled this method may create a new proxy or return an existing proxy; if it does not exist, throw an exception.

        When nullable is enabled, the method does not create new proxies (but might return an existing proxy); if it does not exist, return null.

        When eager is enabled, the object is eagerly fetched

        Throws:
        HibernateException
      • list

        List list​(Criteria criteria)
        Execute a criteria query
      • getContextEntityIdentifier

        Serializable getContextEntityIdentifier​(Object object)
        Return the identifier of the persistent object, or null if not associated with the session
      • bestGuessEntityName

        String bestGuessEntityName​(Object object)
        The best guess entity name for an entity not in an association
      • getDontFlushFromFind

        int getDontFlushFromFind()
      • setCacheMode

        void setCacheMode​(CacheMode cm)
      • setFlushMode

        @Deprecated
        void setFlushMode​(FlushMode flushMode)
        Deprecated.
        (since 5.2) use setHibernateFlushMode(FlushMode) instead
        Set the flush mode for this session.

        The flush mode determines the points at which the session is flushed. Flushing is the process of synchronizing the underlying persistent store with persistable state held in memory.

        For a logically "read only" session, it is reasonable to set the session's flush mode to FlushMode.MANUAL at the start of the session (in order to achieve some extra performance).

        Parameters:
        flushMode - the new flush mode
      • getFlushMode

        FlushModeType getFlushMode()
        Get the flush mode for this session.

        For users of the Hibernate native APIs, we've had to rename this method as defined by Hibernate historically because the JPA contract defines a method of the same name, but returning the JPA FlushModeType rather than Hibernate's FlushMode. For the former behavior, use getHibernateFlushMode() instead.

        Returns:
        The FlushModeType in effect for this Session.
      • setHibernateFlushMode

        void setHibernateFlushMode​(FlushMode flushMode)
        Set the flush mode for this session.

        The flush mode determines the points at which the session is flushed. Flushing is the process of synchronizing the underlying persistent store with persistable state held in memory.

        For a logically "read only" session, it is reasonable to set the session's flush mode to FlushMode.MANUAL at the start of the session (in order to achieve some extra performance).

        Parameters:
        flushMode - the new flush mode
      • flush

        void flush()
      • isEventSource

        boolean isEventSource()
      • afterScrollOperation

        void afterScrollOperation()
      • shouldAutoClose

        boolean shouldAutoClose()
      • isAutoCloseSessionEnabled

        boolean isAutoCloseSessionEnabled()
      • isQueryParametersValidationEnabled

        default boolean isQueryParametersValidationEnabled()
      • getLoadQueryInfluencers

        LoadQueryInfluencers getLoadQueryInfluencers()
        Get the load query influencers associated with this session.
        Returns:
        the load query influencers associated with this session; should never be null.
      • getExceptionConverter

        ExceptionConverter getExceptionConverter()
        The converter associated to a Session might be lazily initialized: only invoke this getter when there is actual need to use it.
        Returns:
        the ExceptionConverter for this Session.
      • createQuery

        @Deprecated
        <T> QueryImplementor<T> createQuery​(String jpaqlString,
                                            Class<T> resultClass,
                                            Selection selection,
                                            HibernateEntityManagerImplementor.QueryOptions queryOptions)
        Deprecated.
        (since 5.2) - see deprecation note on org.hibernate.jpa.spi.HibernateEntityManagerImplementor#createQuery(java.lang.String, java.lang.Class, javax.persistence.criteria.Selection, org.hibernate.jpa.spi.HibernateEntityManagerImplementor.QueryOptions)
        Returns:
        The typed query
      • getPersistenceContextInternal

        PersistenceContext getPersistenceContextInternal()
        This is similar to getPersistenceContext(), with two main differences: a) this version performs better as it allows for inlining and probably better prediction b) see SessionImplgetPersistenceContext() : it does some checks on the current state of the Session. Choose wisely: performance is important, correctness comes first.
        Returns:
        the PersistenceContext associated to this session.
      • isEnforcingFetchGraph

        default boolean isEnforcingFetchGraph()
      • setEnforcingFetchGraph

        default void setEnforcingFetchGraph​(boolean enforcingFetchGraph)