Is using Transaction management mandatory while performing operations with db in Spring Hibernate?
posted 3 years ago
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??
I sure would hope you would want to roll back for that You can set the rollback strategy on the @Transactional annotation, so if you do not want a rollback to it there.
Database operations require transactions. Even if you do not create one the database will create one around that single operation. When this is the case with writes people use autocommit= true. I do not recommend this. I would always use a transaction in your spring code on any operation that writes to the database.