[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1109
  • Last Modified:

HibernateUtil.getSessionFactory().close()

Hi,

I wou.d like to know what is HibernateUtil.getSessionFactory().close() method in hibernate. Where and how and why to use it. How is it different from session.close used in CRUD operations. Any ideas, resources, links, sample code highly appreciated. thanks in advance.
0
gudii9
Asked:
gudii9
  • 3
  • 2
  • 2
2 Solutions
 
for_yanCommented:


HibernateUtil.getSessionFactory().close()  closes session factory, whereas session.close() closes particular session
I think there is big difference.

This is the explanation of the difference between Sessionfactory and the Session in Hibertnate Tuorial:

http://www.visualbuilder.com/java/hibernate/tutorial/hibernate-architecture-and-api/


1.5.1 SessionFactory (org.hibernate.SessionFactory)

SessionFactory is a thread safe (immutable) cache of compiled mappings for a single database. Usually an application has a single SessionFactory. Threads servicing client requests obtain Sessions from the factory. The behavior of a SessionFactory is controlled by properties supplied at configuration time.

1.5.2 Session (org.hibernate.Session)

A session is a connected object representing a conversation between the application and the database. It wraps a JDBC connection and can be used to maintain the transactions. It also holds a cache of persistent objects,used when navigating the objects or looking up objects by identifier.
0
 
Sathish David Kumar NCommented:
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
gudii9Author Commented:
which one is HibernateUtil  class here. Does it not provided by hibernate framework by default. I am not clear. please advise
0
 
gudii9Author Commented:
any good video tutorials, online trainings on these intricate concepts. please advise
0
 
for_yanCommented:

This seesm to be the most viewed Youtube tutorial on Hibernate:

http://www.youtube.com/watch?v=xQMqhWIUbEs

And great majority liked it.
This is the first part - then follow the links on YouTube
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now