I had a *really* close look into the possibility that Hibernate issues the unclosed session WARNing when the session has in fact been closed and I've concluded that it doesn't. I am quite certain that the problem is that the user is not closing the sessions. (In a couple of previous complaints about this, that turned out to be the case.)
As to the use of finally, cleanup code that *must* be executed is *exactly* the role of the finally block, as per any Java textbook. And it is completely predictable. Method exit cannot occur without execution of the finally block. Are you sure the redbook wasn't talking about finalize(), which *is* unreliable? > -----Original Message----- > From: Brad Clow [mailto:[EMAIL PROTECTED] > Sent: Tuesday, 3 December 2002 9:01 PM > To: Aapo Laakkonen > Cc: [EMAIL PROTECTED] > Subject: Re: [Hibernate] Lazy Collections > > > > 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 > > > > ------------------------------------------------------- > This SF.net email is sponsored by: Get the new Palm Tungsten T > handheld. Power & Color in a compact size! > http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en > _______________________________________________ > hibernate-devel mailing list [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/hibernate-devel > ********** CAUTION - Disclaimer ********** This message may contain privileged and confidential information. If you are not the intended recipient of this message (or responsible for delivery of the message to such person) you are hereby notified that any use, dissemination, distribution or reproduction of this message is prohibited. If you have received this message in error, you should destroy it and kindly notify the sender by reply e-mail. Please advise immediately if you or your employer do not consent to Internet e-mail for messages of this kind. Opinions, conclusions and other information in this message that do not relate to the official business of Expert Information Services Pty Ltd ("The Company") shall be understood as neither given nor endorsed by it. The Company advises that this e-mail and any attached files should be scanned to detect viruses. The Company accepts no liability for loss or damage (whether caused by negligence or not) resulting from the use of any attached files. **EIS******** End of Disclaimer ********** ------------------------------------------------------- This SF.net email is sponsored by: Microsoft Visual Studio.NET comprehensive development tool, built to increase your productivity. Try a free online hosted session at: http://ads.sourceforge.net/cgi-bin/redirect.pl?micr0003en _______________________________________________ hibernate-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/hibernate-devel