views:

646

answers:

1

Currently I'm using a session-per-request approach to manage Hibernate sessions in a Java web application. I heard the term session-per-conversation thrown around and was wondering what situations it suits and what benefits it can bring over session-per-request?

A: 

One of the main benefits I've experienced is that you can implement behavior where not every change should directly be committed to the database -- Session per conversation will allow you to set up objects over multiple requests, and only commit to the db on the final 'yes I really want to do this' action. Typical scenarios for this are things like booking a hotel room using a wizard-like series of pages.

Simon Groenewolt