Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

difference between releasing session and closing connection in hibernate ?

 
raj chopra
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

some part of code uses releasing session after each sessions and connections in finally block .

sample code



In the above function i plan to close the session,result set and prepared statements
something like this type



however i want to understand the clear difference between the above two solution .

the suitable solution or the right step to follow will be helpful. thanks for reading this.
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some part of what code? What you have posted does not make sense to me. It looks like straight JDBC with a hibernate session thrown in that is not being initialized or used. Unless releaseSession(session) has a null check it will cause a null pointer exception. If you are using hibernate correctly you should not even have code like the snippet you posted.
 
raj chopra
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bill Gorder wrote:Some part of what code?


Bill,

With all do respect i am still a newbie to hibernate , adding to that my project is integration of springs,struts and hibernate .
My true idea was to close the database connections used while executing,updating,deletions of queries through out my project.
To be specific some class files uses hibernate connections and session and some class files simple jdbc sessions and connection and so i need to deal this incosistent code.
While dealing with this closing the connections, i came acros hibernate sessionrelease and jdbc connectionclose options,so in that context i posted this above query to get claer idea betweeen. how ever a simple connection close would solve my exception was finalised.
Sorry as this info was not posted in firstplace.

code casuing the exception for max open cursor is below, and i am trying to fix this class file to close the connections


Tomcat excpetion was



kindly guide me to resolve this exception.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic