hibernatesessionsessionfactory

Differences between session vs session factory - Hibernate?


Do we have any other differences other than the below? Also please validate whether the below are correct

  1. SessionFactory objects are one per application and Session objects are one per client.
  2. SessionFactory is to create and manage Sessions. Session is to provide a CRUD interface for mapped classes, and also access to the more versatile Criteria API.
  3. SessionFactory is thread safe where as Session is not thread safe

Solution

  • First of all, asking the difference between these interfaces doesn't make any sense. It seems like asking the difference between car manufacturing plant and car. A manufacturing plant is a place where the cars will be produced. Similarly, SessionFactory is an instance which will create Session objects.