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.

Reply via email to