spring - Should one close Hibernate Session object every time after performing any CRUD operation? -
I am working with an enterprise application that uses Spring 3.x with Hibernate annotated programming. . Working with the hibernate session object for the DB function in my
XYZDaoImpl class.
And I suspect "is the correct way to shut down the hibernate
session every time after any kurt operation object?"
If this is correct If not, please advise me to recommend opening / closing hibernate
session objects.
You can post a little bit of DOIPL code ......
If you use sessionFactory.getCurrentSession () , you can get current session..in. This case framework automatically flags and closes when the transaction ends (committed or rollback).
If you use sessionFactory.openSession () , you have to conduct a session and flush it and close it manually.
Comments
Post a Comment