Transactions are defined at the service level, as is typical.
But upon occasion we have a DAO method which requires a higher, SERIALIZABLE, isolation level.
But knowledge of whether the SERIALIZABLE isolation level is necessary is encapsulated in the DAO method, the service method need not know about this.
How can I enforce SERIALIZABLE isolation level at the DAO method level? I can’t even find a way to identify what the isolation level is in Spring.
The service layer typically defines the transactional semantics.
But … you can add the following annotation to achieve the serializable isolation level on the DAO implemenation method to achieve the effect:
The MANDATORY is so that the DAO method will not create a transaction if none exists. This will force all invocations to start from a service method. You can change that if desired.
Let me know how it works out.