posted 13 years ago
Hi All,
Im really new to hibernate, its been a week now on lingering through the codes that im handling now. im just using a lower version, i think its 1.1.x
right now im cleaning the codes as there are some hibernate sessions which are not closed
once a query or update is called. My task was to clear them up which consumes memory after using them.
Here is a sample of the current code:
public java.util.List findBook()
{
return findBook(getSession());
}
the solution i though off was
public java.util.List findBook()
{
Session sess = null;
try
{
sess = getSession();
return findBook(sess);
}
finally
{
SessionFactoryUtils.closeSessionIfNecessary(sess, getSessionFactory());
}
}
I like to ask any comments if what ive done is correct. or should do something else.
many thanks.