Do you use AOP to manage database transactions?

And back, I wrote an application in which Spring AOP to determine which methods were transactional. Now I have a second thought about what a great idea; I was amazed several times after a little refactoring (change of method signatures, etc.), which, of course, does not become obvious until something goes wrong (and I have a logically inconsistent database).

So, I am interested in a few things:

  • Should other people decide to return to explicit transaction management (e.g. via annotations @Transactional)?
  • Are there any useful tools that I can use as part of the build process to determine if something was β€œbroken”?
  • If people use AOP to manage transactions, what steps do they take to avoid the mistakes I made?

I use IntelliJ IDEA, which allows you to view decorated methods and reorganize the Spring configuration XMLalong with changes to the method name, but this is not always enough (adding a parameter to the method in the wrong place may affect whether any aspect works)

+3
source share
3 answers

Java, , , @Transactional. , : , , , .

/, , . , , . , , , , , @Transactional . Spring , .

+4

(1): @Transactonal , . Spring AOP, JDBC-/TransactionManager, @Transaction .

(2): , , , , . Spring AbstractTransactionalJUnit4SpringContextTests/AbstractTransactionalTestNGSpringContextTests . .

+2

, , , autocommit . , , , .

0
source

Source: https://habr.com/ru/post/1704416/


All Articles