wood burning stoves 2.0*
The moose likes Spring and the fly likes Is using Transaction management mandatory while performing operations with db in Spring Hibernate? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Is using Transaction management mandatory while performing operations with db in Spring Hibernate?" Watch "Is using Transaction management mandatory while performing operations with db in Spring Hibernate?" New topic
Author

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

shivang sarawagi
Ranch Hand

Joined: Jun 19, 2008
Posts: 148
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

Joined: Mar 07, 2010
Posts: 1672
    
    7

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.


[How To Ask Questions][Read before you PM me]
 
 
subject: Is using Transaction management mandatory while performing operations with db in Spring Hibernate?