Reputation: 387
I want to use the same function in DAO, suppose getBalances()
with secure SERIALIZABLE
isolation:
@Transactional(isolation=Isolation.SERIALIZABLE)
public List<Balance> getBalances() { ... }
in important business logic method:
public doVeryImportantFinancialChanges() {
.. complicated logic with multiple getEntries() calls, multiple SELECT/UPDATE...
}
but also I want to have unsafe "life view" of balances called every 1-2 seconds with SELECT
only and acceptable broken integrity and all those nonrepeatable, phantom etc. data.
The problem is that my "life view" scheduled SELECT
requestor uses getBalances()
highly isolated function, and gets:
org.springframework.dao.DeadlockLoserDataAccessException: PreparedStatementCallback; SQL [SELECT * FROM ....]; Deadlock found when trying to get lock; try restarting transaction;
How to achieve double (safe-serializable and unsafe) access to same method getBalances() from different call sources?
Upvotes: 1
Views: 435
Reputation: 7957
Try using @Transactional(propagation = Propagation.MANDATORY)
on getBalances
and define the isolation on the calling service.
Upvotes: 3