i have question you. have component have 2 methods. first method needs attached outher transacion started component present chain (i use spring integration), , second 1 must attached (for application design) anoter transaction. behaviour want when second method throw exception, first method starts , re-attaching outher transaction job. try use "nested" propagation of spring framework without success.
this example:
public componentclassinterface{ @transactional(propagation = propagation.requires_new, rollbackfor=exception.class) /*but have used nested without success , don't want use same transaction */ public objectmessage activate(objectmessage message);
}
public componentabstractclass implements componentclassinterface{ public void updateobjectmessage(objectmessage message){ /*to obtain attached instance of persisted message*/ objectmessage message = daomessage.getmessagebyid(message.getid);/*here can't retreive message...the transaction isn't yet attached*/ message.setsomeproperty("changedpropertyvalue"); daomessage.updateitem(message); } @override public abstract objectmessage activate(objectmessage message);
}
public componentconcreteclass extends componentabstractclass{ @override public objectmessage activate(objectmessage message){ ............ dosomestuff ............ }
}
the objective find solution permits me don't rewrite/rethink application flow , mantain classes upon.
regards
damiano
transactions in spring supported through aop , proxies. means if method of class instance calls method of same instance, doesn't invoke method through spring proxy, , spring can't intercept call , start new transaction you. need put method requires_new
propagation inside spring component.
Comments
Post a Comment