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);
}
}
- Does the
@Transactional
behavior propagate to myPrivateMethod even if it's private?. - If a
Runtime Exception
occurs onprocessSomething()
, andprocessSomething
is called frommyPrivateMethod
, willmyPrivateMethod
andmyMethod
do rollback?. - If the answer to 1 and 2 is no, how can I achieve that without having to create another
@Service
?. How can I do extract method and invoke multiple private methods inside a public service method within a@Transactional
context?. - Is
isolation=Isolation.SERIALIZABLE
option a good alternative tosynchronized
methods?.
I know this has been answered already but I'm still having doubts.