aspose file tools
The moose likes Object Relational Mapping and the fly likes Hibernate Helper Class Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Reply 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: 17234
    
    1

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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Hibernate Helper Class
 
Similar Threads
hbm file version working but annotation not
Problem using Annotations in hibernate
could not read mapping from resource
Problem deploying service on Ubuntu Virtual Machine
Hibernate:Nullpointer exception