Package org.springframework.orm.hibernate5

# Class SessionHolder

java.lang.Object
org.springframework.transaction.support.ResourceHolderSupport
org.springframework.orm.jpa.EntityManagerHolder
org.springframework.orm.hibernate5.SessionHolder

All Implemented Interfaces:
  `org.springframework.transaction.support.ResourceHolder`

public class SessionHolder extends EntityManagerHolder
Resource holder wrapping a Hibernate `Session` (plus an optional `Transaction`). `HibernateTransactionManager` binds instances of this class to the thread, for a given `SessionFactory`. Extends `EntityManagerHolder` as of 5.1, automatically exposing an `EntityManager` handle on Hibernate 5.2+.

Note: This is an SPI class, not intended to be used by applications.

Since:
  4.2
Author:
  Juergen Hoeller
See Also:
  - `HibernateTransactionManager`
  - `SessionFactoryUtils`

## Constructor Summary

Constructors
Constructor
Description
`SessionHolder(Session session)`

## Method Summary

Modifier and Type
Method
Description
`void`
`clear()`
`FlushMode`
`getPreviousFlushMode()`
`Session`
`getSession()`
`Transaction`
`getTransaction()`
`void`
`setPreviousFlushMode(FlushMode previousFlushMode)`
`void`
`setTransaction(Transaction transaction)`

### Methods inherited from class org.springframework.orm.jpa.EntityManagerHolder

`getEntityManager, getSavepointManager, isTransactionActive, setSavepointManager, setTransactionActive`

### Methods inherited from class org.springframework.transaction.support.ResourceHolderSupport

`getDeadline, getTimeToLiveInMillis, getTimeToLiveInSeconds, hasTimeout, isOpen, isRollbackOnly, isSynchronizedWithTransaction, isVoid, released, requested, reset, resetRollbackOnly, setRollbackOnly, setSynchronizedWithTransaction, setTimeoutInMillis, setTimeoutInSeconds, unbound`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### SessionHolder

public SessionHolder(Session session)

## Method Details

### getSession

public Session getSession()

### setTransaction

public void setTransaction(@Nullable Transaction transaction)

### getTransaction

@Nullable public Transaction getTransaction()

### setPreviousFlushMode

public void setPreviousFlushMode(@Nullable FlushMode previousFlushMode)

### getPreviousFlushMode

@Nullable public FlushMode getPreviousFlushMode()

### clear

public void clear()

Overrides:
  `clear` in class `EntityManagerHolder`