Open Session in View. Sessions and transactions is required reading to understand this pattern.
This page describes Hibernate 3.1.x and code shown here does not work in older versions. The problem A common issue in a typical (web-)application is the rendering of the view, after the main logic of the action has been completed, and therefore, the Hibernate Session has already been closed and the database transaction has ended. Sessions and transactions. This page explains common techniques to deal with the Session and transactions in Hibernate applications.
Refer to the Hibernate reference documentation and the "Transactions and Concurrency" chapter for more information. This page describes Hibernate 3.1.x and code shown here does not work in older versions. Unit of Work A particular unit of work is grouping data access operations. Generic Data Access Objects.
This is a pattern for Data Access Objects with JDK 5.0, from the CaveatEmptor example application.
It is also explained in the book Java Persistence with Hibernate . Two links you might find useful: Sessions and transactions and Open Session in View .