java - Stopping looped notifications with VetoableChangeListener -
i have problem design of vetoablechangelistener
. implement vetoablechangelistener
interface listen changes of property in model class, when model fires
vetoablechange(propertychangeevent evt) throws propertyvetoexception
…i try save change in db, fail (by sqlexception
, example). if fails throw propertyvetoexception
revert changes in model.
the model delegating in vetoablechangesupport
(jdk class), when receives propertyvetoexception
catches , notifies revert vetoablechangelistener
, oldvalue
/newvalue
interchanged (later rethrows exception), event comes class again , try save in db again, etc...
i have workaround model not change until nobody throws propertyvetoexception
, in vetoablechangelistener
first check if data i'm going save in database not equal data in model, if it's equal ignore change.
is there another, better workaround?
your "workaround" not workaround in fact sounds proper solution me: confirming there in fact change current state of object prior attempting "change" persisted version. more efficient (database access expensive).
Comments
Post a Comment