I am trying to upgrade my application from spring 3.3.x to Spring 4.1. Most of the upgrade has gone smoothly but we see some strange issue with respect to Transaction propagation. We have one service layer class method annotated with @Transactional (read-only=true) calling another lower layer class method annotated with @Transactional (read-only=false) .Both of them are proxied via interfaces and the logs show the TransactionInterceptor being invoked. But when the save is called on the database we get.
"Connection is read-only. Queries leading to data modification are not allowed; "
The previous release of spring works perfectly fine as does spring 4.0.9. But once I switch to 4.1 this error is thrown . Any ideas ? I was under the impression that the transaction is modified to read-write at any point during the invocation if such an advice is hit if the current transaction was initiated as read-only and I have used this like it for a while . Below is the code of something like we are doing. We are using Hibernate 4.1 with JpaTransactionManager as our transaction manager.
public class Service1Impl implements Service1{
public Service2 service2;
@Transactional(read-only=true)
public Job processJob( Data data){
.....
service2.saveJob(data);
}
}
public class Service2Impl implements Service2{
@Transactional(read-only=false)
public Job saveJob( Data data){
.....
}
}
Any help or suggestion is greatly appreciated
Thanks
readOnly
flag with 4.1 so it is quite possible that you too have been affected by a bug of some sort. – manish