Where to open sessions in a Spring/Hibernate stack?
Posted
by CaptainAwesomePants
on Stack Overflow
See other posts from Stack Overflow
or by CaptainAwesomePants
Published on 2010-05-19T07:29:25Z
Indexed on
2010/05/19
10:20 UTC
Read the original article
Hit count: 292
I'm trying to figure out a good design for a Spring/Hibernate app. When creating such an app, it appears like there are a handful of major decisions.
The first major decision seems to be where to put the session/transaction boundary. It seems like I have 3 major choices: as a filter before controllers are even invoked, immediately below the controllers at the service call level, and stuffed way below the business level in repository calls.
It seems to me like the right call is the middle path, but I'm not sure. I don't want my transactions open too long, but at the same time, I don't want to constantly worry about detached objects and lazy loading in the business logic. Still, there are some downsides. For instance, it makes it hard for the business logic to make a remote call without holding up a transaction for a few seconds. I wonder if there's a better way?
© Stack Overflow or respective owner