DeleteLink onclick() {
User user=userservice.load(userid);
userservice.delete(user);
User user2=userservice.load (userid);
userservice.delete(user2);
}
above onClick() will use "4" seperate transactions.
i.e. If delete(user2) fail, delete(user) won't be rollback !!
PROPOGATION only ocurrs within out-most service method.
On 12/18/05, Igor Vaynberg <
[EMAIL PROTECTED]> wrote:
On 12/17/05, John Patterson <[EMAIL PROTECTED]> wrote:On Saturday 17 Dec 2005 19:24, Igor Vaynberg wrote:
> > Can you call multiple operations on your service interfaces in the same
> > transaction? Or is this not done?
>
> yes. if you mark your service method as PROPOGATION_REQUIRED it will join a
> transaction if one exists, or start a new one if one doesnt.
I assume the service methods would need to be called by another Spring-managed
method (service method) - ie not called sequentially from your wicket event
handler - to be included in the same transaction?
noep. that is the beautiy of aop and how well transactions fit as an aspect. in the spring context you declare a transactional interceptor for your service ( in case of jdk5 you can simply mark some methods with @Transactional and then spring can do it for you automatically). So when you say context.getBean(IUserService) you get back an aop-decorated wrapper of your IUserService implementation. It has all the transactional logic in it so you use it as you would a regular service and in background spring handles all the transaction details.
so my onclick handler looks like this
DeleteLink onclick() { User user=userservice.load(userid); ..... userservice.delete(user); }
no mention of transactions anywhere in your code.
I also like Pico. it is great for small projects that do not require a lot. I used it back in struts and maverick days. Spring offers everything Pico does, and a ton more that i think every web based project can benefit from.
-Igor
--
Ingram Chen
Java [EMAIL PROTECTED]
Institue of BioMedical Sciences Academia Sinica Taiwan
blog: http://www.javaworld.com.tw/roller/page/ingramchen
