Hello. I am using Hibernate framework in my application. I have numbers of Dao class in my application. Each Dao class contains few methods connecting to database.
I have created a reusable Code for this. Following is my code :
Now, i just need to put DbUtil.getHibernateConnection() and DbUtil.closeHibernateConnection() in my Dao class methods. And in between these two methods lies my logic. Is this a good approach?
Or i should create the necessary objects inside the constructor of each Dao classes?
Also provide your valuable suggestions and advice
posted 4 years ago
Yes,You can have get and close methods of session.get method should take care of creating a new seesion or getting exisiting one.close method should be used for cleaning resources and closing sessions if not active in any transactions.
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads