Certainly, I don't see this logic. What gets injected into both service A and service B should by the perthread proxy to the Hibernate Session service. This implements all the Session methods but delegates to a per-thread instance that is discarded at the end of the request.
The thing to watch out for is if you try to acquire the *real* Hibernate session object from the SessionManager service; this is not proxied and is not thread safe. If you store somewhere, such as a static field, or an instance field of a singleton service, or the HttpSession, you are opening yourself up for some hurt! On Wed, Jul 21, 2010 at 9:33 AM, Jim O'Callaghan <jc1000...@yahoo.co.uk> wrote: > I have a service (service A) that creates some sample data, consisting of a > reasonably detailed object graph where all the relations are cascaded. This > service makes use of another service (service B) which manages the save of > the parent entity. Service B has the hibernate session injected at bind > time. I have service A called in a finite loop in the setup (@SetupRender) > method of a scratch page I use for some dev testing. To cut a long story > short, when playing around with the sample data creation, I found I was > getting some "non thread safe access to session" type messages when I > launched a second user session and hit the same scratch page. This doesn't > happen if I mark the relevant method in service A as synchronized, but this > brings with it a significant performance penalty. I'm a little concerned I > may have a situation where in a high traffic scenario multiple users hitting > the same service methods may get the same error. Can anyone reiterate the > best practise approach for marking member fields / injected parameters as > final or point me to a relevant posting on it around here - I'm sure > something about marking things as final was brought up on the list not so > long ago but for the life of me I can't find it. I'm not sure if it's > relevant but I'm using T5.2.0-SNAPSHOT. Perhaps this isn't Tapestry relevant > at all and is down to my use of Hibernate. Thanks. > > > > Regards, > > Jim. > > -- Howard M. Lewis Ship Creator of Apache Tapestry The source for Tapestry training, mentoring and support. Contact me to learn how I can get you up and productive in Tapestry fast! (971) 678-5210 http://howardlewisship.com --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org