Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Not a perfect Hibernate util class

 
Kunal Lakhani
Ranch Hand
Posts: 622
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using hibernate with swing. I am creating a util class for getting necessary objects like Configuration and sessionfactory.

Here is the code




Here is my Dao class that uses this DBUtil class



The swing form using this Dao class, runs continuously (adding and editing, thus calling these 2 methods number of times). So i am confused where to close the session and Sessionfactory.

What should i do?
 
Kunal Lakhani
Ranch Hand
Posts: 622
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Should i go for separate method for getting connection related objects and closing connection related objects? And every time i need that (like inside action performed method for SUBMIT and EDIT) i should call both these 2 methods?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic