Solved

HibernateUtil.getSessionFactory().close()

Posted on 2011-03-24
7
1,038 Views
Last Modified: 2012-05-11
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
Comment
Question by:gudii9
  • 3
  • 2
  • 2
7 Comments
 
LVL 47

Accepted Solution

by:
for_yan earned 400 total points
ID: 35212013


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
 
LVL 20

Assisted Solution

by:Sathish David Kumar N
Sathish David  Kumar N earned 100 total points
ID: 35213247
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 35213352
0
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
LVL 7

Author Comment

by:gudii9
ID: 35353907
which one is HibernateUtil  class here. Does it not provided by hibernate framework by default. I am not clear. please advise
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 35356628
0
 
LVL 7

Author Comment

by:gudii9
ID: 35463003
any good video tutorials, online trainings on these intricate concepts. please advise
0
 
LVL 47

Expert Comment

by:for_yan
ID: 35463097

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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Convert from a json string array to a Java object 3 64
Bot application - advice 3 61
Eclipse with various Java releases 7 48
Java array 10 63
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question