Is Hibernate Session a Thread-Safe Object?

No. Hibernate Session object is not thread-safe, every thread should get its own session instance and close it after it’s work is finished. In other words, you cannot share it between threads.

Hibernate Session is a single-threaded, short-lived object conceptually modeling a "Unit of Work". In JPA nomenclature, the Session is represented by an EntityManager.
Behind the scenes, the Hibernate Session wraps a JDBC java.sql.Connection and acts as a factory for org.hibernate.Transaction instances. It maintains a generally "repeatable read" persistence context (first level cache) of the application domain model.

Comments