I have some doubt about closing session after its use.
I don't wanna have to close the session explicity, because I'm using DAO Design Pattern, so I was thinking in something like this:
What about to close the session in the finalize() method?
Code:
protected void finalize() throws Throwable{
try {
//close session
}
}catch (Exception ex) {}
}
This will avoid the problems related to lazy loading, because the session will be closed before garbage collection, and at this time, probably this object is not used anymore.
Is there some problem with this aproach?
Thanks a lot,