Search code examples
springtransactionsspring-transactions

When using spring @Transactional,who eventually does the isolation and propagation work,the springframework or the database?


Which one is happening:the framework tells the database to start a transaction and using the isolation level set in @Transaction, or the framework handle everything and the database doesn't know a thing about it?

And if the database does the work, what will happen when you set isolation in @Transactional to a level the database doesn't support,for example,set it to Repeatable Read but the database is oracle?


Solution

  • the framework tells the database to start a transaction and using the isolation level set in @Transactional

    yes

    what will happen when you set isolation in @Transactional to a level the database doesn't support

    In the end, it boils down to setting the isolation level on the JDBC connection returned by the JDBC driver. I'm not sure if there are strict rules in the spec (the javadoc doesn't help much), but I assume a SQLException will (or at least should) be thrown by the JDBC driver. Try it, and you'll see.