Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
shivang sarawagi
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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??
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic