Open taras opened 11 years ago
you can have a look at the shadow of session as described in comment of this issue https://github.com/GroupTalent/epf/issues/22
@c0urg3tt3 works, is this how it should be done going forward?
I am probably going to add a rollback
method to session at some point. But the more idiomatic way to do this is to use a child session (e.g. session.newSession()
). To cancel all the changes that have taken place in a child session you can just opt to never call flush.
We use childSession when we have a dedicated edit view but as far as I can tell there are some situations where using a childSession isn't possible. For example, we have a customer profile page that allows a user to edit the name and other attributes in place without having to first click an edit button. If the user escapes from the input while editing, we need to rollback. I'm not sure how this would be done using a childSession.
@jasonkriss this is partially why the current behavior for childSessions is to flush into the parent session immediately. In your profile case you could create a child session upon edit and simply flush when they click save.
I have a cancel button in an edit view and I'd like to cancel all changes when that button is pressed.
Do I manipulate the session or the model to rollback the changes?