-
Book Overview & Buying
-
Table Of Contents
Java Hibernate Cookbook
By :
First, we will discuss SessionFactory and how to create it in detail. As the name suggests, a SessionFactory is a factory of sessions.
A SessionFactory has the following features:
It's an interface implemented using the singleton pattern.
It's created using the configuration provided by the configuration file.
It's thread-safe, so it's created once during the application's lifetime, and multiple users or threads can access it at the same time without any concurrency issue.
As a SessionFactory object is immutable, changes made to the configuration will not affect the existing factory object.
It's a factory class, and its main duty is to create, manage, and retrieve a session on request. A Session is used to get a physical connectivity with the database.
If you are using a version of hibernate that is earlier than 4, use the following code to create a SessionFactory:
/* Line 1 */ Configuration cfg = new Configuration(); /* Line 2 */ cfg = cfg.configure(); /*...
Change the font size
Change margin width
Change background colour