Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

HibernateUtil.getSessionFactory().close()

Posted on 2011-03-24
7
1,028 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
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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
oracle 11g 23 106
factorial example 4 47
Java: anonymous class 4 29
Is there a simpler dropbox system? 10 34
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to implement Singleton Design Pattern in Java.

807 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