From: Brad C. <bra...@wo...> - 2002-12-03 10:01:00
|
> I have also other problems with lazy collections. I get WARNings about > Unclosed Sessions (finalize method in SessionImpl). I use Maverick Web > MVC Framework and it has discard() method in one interface that you can > implement. I have put my Session closing code in it, but it doesn't > help. It continues to leave sessions open. I have tried almost > everything, but I cannot get rid of those Unclosed Sessions. Only > solution I have found is closing session before going to a view > rendering phase, and that means that lazy initialization is not an > option anymore. on the project i am currently working on we use a servlet filter to open a connection in a try block and stick the close connection in a finally block. we r not having any probs with lazy initialisation or unclosed sessions. however, we r also not using the absolute latest version of hibernate. > Also I see that Hibernate uses a lot of finally {} blocks to do some > cleaning. If I understand correctly, at least what I have read from some > of IBM's whitepapers, they don't recommend you to use finally {} to do a > cleaning (mainly they don't recommend to put connection closing code in > it) as it cannot be determined when that block gets called. I migth be u definitely don't want to rely on finally blocks to clean up connections, sockets, etc. when it can/should be done some other way. however, aren't they the last line of defence when u r relying on someone else to clean up after themselves? for example, only the developer of the client app knows when they r finished with a session and therefore when to close it. regards brad |