[jboss-user] [JBoss Seam] - How To Cancel Update in Home Object

gzoller do-not-reply at jboss.com
Thu Apr 19 17:19:37 EDT 2007


If I override update() in a Home object, how can I stop the update from happening and roll back changes the user has made?  Even better:  Is there a way to have access to the old and new fields values?

What I'd like to be able to do is know what the original value was so I can manually set it back in update().  Something like this:

  | @Override
  | public String update() {
  |     if( getInstance().getFavoriteColor().equals("Red") ) {
  |            MyHome mh = new MyHome();
  |            mh.setId( getInstance().getId() );
  |            mh.find();  // desired: mh now holds original pre-update() persisted state
  |            getInstance().setFavoriteColor(mh.getFavoriteColor());
  |            return null;
  |     }
  |     return super.update();
  | }

The problem is that the database lookup returns the new value not the original value I'm looking for.  I've also tried using a query rather than find()--same result.  This is puzzling to me!  update() hasn't yet successfully completed, so why is the find() returning the new rather than the old value?

Anybody know how I can get access to both the original and new field values inside update()?


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4039058#4039058

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4039058

More information about the jboss-user mailing list