Reputation: 1207
We have Spring MVC based web-app having service method attributed with @Transactional(readonly=true).
I was expecting spring to throw exception because we have method which is committing data in mysql db.
Can anyone help me out why transaction attribute (Readonly) related exception is not thrown ?
below mentioned is code...
@Service
@Transactional
public class AppService {
... @Autowired Dao
public int createApplication(AppVO vo){
....
}
}
Upvotes: 2
Views: 1164
Reputation: 64059
Taken straight from the Javadoc of readOnly
of @Transactional
is the following:
This just serves as a hint for the actual transaction subsystem; it will not necessarily cause failure of write access attempts. A transaction manager which cannot interpret the read-only hint will not throw an exception when asked for a read-only transaction.
So it is not unexecpected that an exception is not thrown.
Upvotes: 3