Solved

HibernateUtil.getSessionFactory().close()

Posted on 2011-03-24
7
977 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
Comment Utility


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
Comment Utility
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
Comment Utility
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 7

Author Comment

by:gudii9
Comment Utility
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
Comment Utility
0
 
LVL 7

Author Comment

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

Expert Comment

by:for_yan
Comment Utility

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
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 learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

728 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now