O'Reilly logo

Spring Persistence with Hibernate by Ahmad Seddighi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using a single instance of SessionFactory

As mentioned in Chapter 3, the application uses session objects to interact with Hibernate and to request Hibernate to perform a persistence operation. This means the application needs to obtain a session object before issuing a persistence request. These objects are not thread-safe, so they cannot be shared. They undertake transactions, manage caching, and provide other controls on the persisting of the entity objects. However, session objects are not directly instantiated. Instead, they are constructed by another object called SessionFactory, which is thread-safe and acts as a factory for sessions.

As you saw in Chapter 3, the SessionFactory object is also not directly instantiated directly. Instead, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required