> I don't close the session at all in any of my business logic methods. In
> deployment, a servlet filter _always_ closes the session at the end of the
It looks like not the good way for performance. As I understand
"doFilter()" returns after output is sent and
connection is open/locked too long ( waits for "out.flush()" ).
I have never used Fillter to close connection in production (I close it in
"controler" or "dispatcher"), but this way is very simple, doe's it performs
for you ?
> request. For unit testing, I have a base test case class that does the
same
> thing in the tearDown() method. That way, each test case can execute in
the
> same manner as the app running in deployment (i.e. each test case is like
a
> separate "request"). The result is each test case executes using the same
> session, and they don't need to worry about closing it at the end.
>
> Hope this helps...
>
> Joe
>
> ----- Original Message -----
> From: "Matthew E.Porter" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, August 05, 2003 11:12 PM
> Subject: [Hibernate] Unit Testing With ThreadLocal Sessions
>
>
> > Greetings. I am interested in hearing how people unit test method that
> > call session.save(), update(), and delete() when the session is
> > provided via the ThreadLocal pattern. For me, the primary question is
> > whether or not the method containing the session method calls actually
> > closes the database connection (session.close()) or is it called after
> > returning from the tested method. From a pure unit testing
> > stand-point, it would seem that it would be desired to be called inside
> > the tested method.
> >
> > For a project I am working on, we devised a solution (aka hack) to
> > solve this. A new Session interface implementation was created that
> > wraps an internal Session object as normally provided. Yet, we added 2
> > methods: suspendClose() and unsuspendClose(). When closes are suspend,
> > the connection is NOT closed despite being called. Specifically, it
> > does not call session.close() on the internal Session object.
> >
> > When a Session is retrieved, the closes are automatically suspended.
> > The servlet filter unsuspends the close and closes the session if
> > necessary at the end of the request.
> >
> > Is this a hack? Yes. Does it work? Yes. Do we get the benefits of a
> > ThreadLocal session? Yes. Can it be confusing to newbies who expect
> > close to actual close the session? Yes, but it only has this behavior
> > during deployment.
> >
> > Any thoughts and comments are welcome.
> >
> >
> > Cheers,
> > matthew
> >
> >
> >
> > -------------------------------------------------------
> > This SF.Net email sponsored by: Free pre-built ASP.NET sites including
> > Data Reports, E-commerce, Portals, and Forums are available now.
> > Download today and enter to win an XBOX or Visual Studio .NET.
> >
>
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
> > _______________________________________________
> > hibernate-devel mailing list
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/hibernate-devel
> >
> >
>
>
>
>
> -------------------------------------------------------
> This SF.Net email sponsored by: Free pre-built ASP.NET sites including
> Data Reports, E-commerce, Portals, and Forums are available now.
> Download today and enter to win an XBOX or Visual Studio .NET.
>
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
> _______________________________________________
> hibernate-devel mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/hibernate-devel
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel