Do we have any other differences other than the below? Also please validate whether the below are correct
SessionFactory
objects are one per application and Session
objects are one per client.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
. SessionFactory
is thread safe where as Session
is not thread safeFirst 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.
SessionFactory
is a factory class for Session
objects. It is available for the whole application while a Session
is only available for particular transaction.
Session
is short-lived while SessionFactory
objects are long-lived. SessionFactory
provides a second level cache and Session
provides a first level cache.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With