Java Reference
In-Depth Information
8.2 Managing connections using a Spring filter
Lazy loading requires the persistence framework connection— JDO Persistence-
Manager or Hibernate Session —used to load the root object to remain open. When
the application traverses a relationship to an unloaded object, the persistence
framework uses that connection to load it. Consequently, when using the Exposed
Domain Model pattern the application must keep the persistence framework con-
nection open while handling a request in order to allow the view components to
load objects lazily. We have seen that a good way to accomplish this is to use a serv-
let filter, which intercepts requests and opens the connection, executes the servlet
and the JSP page, and closes the connection. Figure 8.4 shows how a request is han-
dled in an application that uses a servlet filter to manage connections.
:Web
Container
:Persistence
Framework
:Domain
Object
:Filter
:Servlet
:JSP
doFilter()
getConnection()
service()
<<forward>>
closeConnection()
Figure 8.4
Using a servlet filter to handle connections
 
 
Search WWH ::




Custom Search