Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Struts 2 »

Re: struts/hibernate/tomcat question

uni

2007-01-02

Replies:

Hi Rick,

I am using a utility class as proposed in the book "Hibernate in Action". The
session and the transaction is stored in a ThreadLocal. The utility class
itself has the following methods:
- getSession / closeSession
- beginTransaction / commitTransaction / rollbackTransaction
In your actions, you only use getSession and beginTransaction. Commiting and
closing can be done using a servlet filter.

This approach makes your business code really clean, the session stays open
until the JSP is rendered and everything is fine ;)

The class looks similar to this one:
https://www.ribesoftware.com/mpo/samples/java.hibernate.flex/htmlsrc.sample.dao.hibernate.HibernateUtil.java.html

Cheers,

Thorsten


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.