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, ...