File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate Helper Class

 
Ryan Waggoner
Ranch Hand
Posts: 75
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ryan Waggoner
Ranch Hand
Posts: 75
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic