Is using Transaction management mandatory while performing operations with db in Spring Hibernate?

StackOverflow https://stackoverflow.com/questions/17149845

Вопрос

I went through Spring transaction management. I have a very simple question assume in a banking application with Spring Hibernate Integration is it mandatory to use @Transactional on credit & debit methods. If I don't want a rollback still do I have to put the methods in a transaction scope??

Это было полезно?

Решение

If you are asking technically whether Hibernate calls have to be in a transaction, the answer is no. Each call (update, insert, or delete) will be done as an atomic action. After the function returns the request to the database will be complete. When the database actually commits the change is up to Hibernate, the driver, and the database itself.

If you are asking whether or not you should put credits or debits into a transaction state, the answer depends on the requirements of the application.

Другие советы

It depends on you haw you handle your debit and credit. Perhaps there is some level configuration you can provide to @Transactional. If you need to have more flexible transaction, you may opt for programmatic transaction management instead of declarative transaction management. As far as Spring is concerned, it do not restrict you in any way, its totally up to you how you want to handle your transactions.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top