yes, sorry i misspoke. every call to the service from outside will have its own transaction, because otherwise how does spring know when the request is over and its time to commit? i always thought that people, at least this was the case with me, used transaction per request because it is the most manageable way to go, not because the semantic of the event handlers really required a single transaction. if it does why arent those operations in their own service method to start with.

-Igor


On 12/17/05, Ingram Chen <[EMAIL PROTECTED]> wrote:
AFAIK, this is not how spring PROPOGATION_REQUIRED working

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

Reply via email to