SessionScopeWebModule exception handling

Showing 1-1 of 1 messages
SessionScopeWebModule exception handling boyan 12/7/10 8:15 PM
Hi guys,

I have a Web app with SessionScopeWebModule enabled, and I wonder how
to best handle business exceptions (not Hibernate / DB exceptions).

I believe AR 2.0 SessionScopeWebModule implicitly implements
transaction - if an exception occurs during the request, changes made
during the session will be discarded / rolled back.

For my Web app, the business layer will be chatty with the DB, issuing
several CRUDs, say

- Create entity A
- Create entity B

Say entity A has been created. However upon creating entity B some
business rules were not observed and the business layer throws a
business exception.

From the UI perspective, it's best to 'handle' the business exception
and display a friendly message back to the user. This is where the
problem lies. If the exception is already handled,
SessionScopeWebModule goes along thinking everything is fine at the
end of the request and commits the entity A into database, without
entity B.

What is the best practice to handle exceptions in this case? I'm
thinking of a session variable that will be reset for each new
request. If an exception occurs, the variable will be marked dirty.
When the request ends, the SessionScopeWebModule will first check the
session to see if any exception has occured. If so, it will invoke a

Is this the way to go? And would FailSession do the job of discarding
changes to a session?