State the role of SessionFactory interface plays in Hibernate.
- The SessionFactory is used to create Sessions. Each application is having usually only one SessionFactory. The requests from the servicing client threads obtain the Sessions from the session factory. SessionFactory is thread safe, so that many threads can access it concurrently and requests the sessions.
State the role of SessionFactory interface plays in Hibernate.
- An application obtains Session instances from a SessionFactory which is typically single for the whole application created during its initialization.
- The SessionFactory caches generate SQL statements and other mapping metadata that Hibernate uses at runtime.
- It also holds cached data that has been read in one unit of work and may be reused in a future unit of work.
SessionFactory sessionFactory = configuration.buildSessionFactory();