aspose file tools*
The moose likes Object Relational Mapping and the fly likes difference between releasing session and closing connection in hibernate ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "difference between releasing session and closing connection in hibernate ?" Watch "difference between releasing session and closing connection in hibernate ?" New topic
Author

difference between releasing session and closing connection in hibernate ?

raj chopra
Ranch Hand

Joined: Apr 09, 2012
Posts: 60
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.

Reagrds,
raj chopra
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1676
    
    7

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.


[How To Ask Questions][Read before you PM me]
raj chopra
Ranch Hand

Joined: Apr 09, 2012
Posts: 60
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.
 
Consider Paul's rocket mass heater.
 
subject: difference between releasing session and closing connection in hibernate ?