myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yee CN <>
Subject RE: Question: Hibernate SessionPerRequest with JSF navigation
Date Thu, 08 Dec 2005 16:40:15 GMT
Thanks. I am using ThreadLocalSesion as well. I am planning to commit and
restart a transaction at the AFTER_APPLICATION Phase - I think that should
be the right place for it. My program seems to be running OK without it - it
seems that Hibernate auto flushing is handling it correctly - at least till
now. I am also wondering whether it is absolutely necessary to implement it
as well.






From: Mufasa [] 
Sent: Thursday, 8 December 2005 10:49 PM
To: 'MyFaces Discussion';
Subject: RE: Question: Hibernate SessionPerRequest with JSF navigation


I use a PhaseListener combined with the ThreadLocalSession approach. If you
use a PhaseListener and close after RENDER_RESPONSE, it will properly run in
the order you want.


Jon Adams



From: Yee CN [] 
Sent: Tuesday, December 06, 2005 11:44 PM
To: 'MyFaces Discussion'
Subject: Question: Hibernate SessionPerRequest with JSF navigation



I have been pondering about this particular issue regarding the usage of
SessionPerRequest with JSF. In the SessionPerRequest pattern, a hibernate
session is open and a transaction started at the beginning of the request,
and the transaction is committed just before returning a response to the


I have been using this pattern for a while until a couple days ago I
realized that a request in JSF usually involves an action that navigates to
another JSF. For example a viewCustomer.jsf could have a delete customer
button, which deletes the customer and navigates to listCustomer.jsf. The
sequence of action is thus:


1. Begin hibernate transaction

2 .deleteCustomerAction()

3. Deletes customer from database

4. JSF navigation to listCustomer.jsf

5. Retrieve and display customer list

6. Commit hibernate transaction


There are two distinctly independent operations within the same Httprequest.
To be correct - the transaction should commit after step 3, and a new
transaction should begin. If I use 'redirect' in JSF navigation that is what
it would amount to. But what is the proper way to inject the commit without








View raw message