I have the following code:
@Service
public class MyService implements IMyService {
@Inject
IAnotherService anotherService;
// injects go here
// some code
@Transactional(isolation=Isolation.SERIALIZABLE)
public Result myMethod() {
// stuff done here
return this.myPrivateMethod()
}
private Result myPrivateMethod() {
// stuff done here
// multiple DAO SAVE of anObject
anotherService.processSomething(anObject);
return result;
}
}
@Service
public class AnotherService implements IAnotherService {
// injections here
// other stuff
@Transactional(isolation=SERIALIZABLE)
public Result processSomething(Object anObject) {
// some code here
// multiple dao save
// manipulation of anObject
dao.save(anObject);
}
}
@Transactional
behavior propagate to myPrivateMethod even if it's private?. Runtime Exception
occurs on processSomething()
, and processSomething
is called from myPrivateMethod
, will myPrivateMethod
and myMethod
do rollback?. @Service
?. How can I do extract method and invoke multiple private methods inside a public service method within a @Transactional
context?. isolation=Isolation.SERIALIZABLE
option a good alternative to synchronized
methods?. I know this has been answered already but I'm still having doubts.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.