First, find out if transactions are for you. Even if things get saved to the DB, if it happens in a transaction you can still roll it back. This is the best solution, as transactions are common to all DB access libraries: the next solution is hibernate-specific.
If there's reasons you can't do that (e.g. there are other objects that you want to update in the same transaction), then you can detach your objects at any time by calling session.evict(obj). Assuming that the problem is that, in your action class, you're doing something like
Code:
A obj = (A) session.load(requestScope.getAttribute("A_identifier"));
boolean success = populateObjectFromPage(requestScope, obj);
if (!success)
{
// Marker
return;
}
session.update(obj);
To "undo" the changes in the !success block, call session.evict(obj) where the Marker comment is.
You can also evict the object earlier, then use session.merge() instead of session.update() to save the detached object.