Meaningless Drivel is fun!*
The moose likes Object Relational Mapping and the fly likes Hibernate Helper Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate Helper Class" Watch "Hibernate Helper Class" New topic
Author

Hibernate Helper Class

Ryan Waggoner
Ranch Hand

Joined: Jun 27, 2007
Posts: 75
I am having trouble figuring out what this class is actually doing. I am using it and it is working fine, just not sure what is working fine...

Anyone have an explanation for me?

Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Basically, what you have is a Singleton. See creating a SessionFactory is a big deal, it has so much work to do. It is considered a heavyweight object. So you want to make sure that you only create this once, hence the Singleton.

So anytime you app needs to get a Session, it can call the helper class Singleton get the instance of SessionFactory and call openSession() on it. Session objects are very lightweight. Almost empty when you call that method, there is a JDBC Connection set in the new Session, but it will get the Connection from the COnnection pool.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Ryan Waggoner
Ranch Hand

Joined: Jun 27, 2007
Posts: 75
Great thanks, I didn't realize that the session factory was going to be such a heavyweight object.

Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate Helper Class
 
Similar Threads
could not read mapping from resource
Problem deploying service on Ubuntu Virtual Machine
hbm file version working but annotation not
Hibernate:Nullpointer exception
Problem using Annotations in hibernate