Spring Transaction Management Facts: (we may call it as business transactions as opposed to db transactions):
1. One of the most compelling reasons to use the Spring Framework is the comprehensive transaction support. Without a transaction, Spring can use a different connections between the two queries back-to-back.
2. Transactions are declared on the method level, but are actually bound to the running thread. It means that once you declare a method as transactional that transaction can span a called method tree of unlimited depth. That's why DAO layer is, normally, not declared as transactional.
3. Transaction is bound to the thread once you start a method declared as transactional. It stays bound to the thread until the method is finished or transaction is suspended. Non-transactional methods do not suspend transactions. Any method in the call tree that knows how to lookup the transaction bound to the thread can do it, no matter if method is marked as transactional or not.
4. Spring does not change autocommit mode or execute commits or rollbacks or do anything to your connection unless explicitly told.
5. Transactional behavior cannot work when autocommit is on.
6. Spring has capability of rollback the transaction in case of checked exceptions also but for that we need to configure the spring beans.xml accordingly.
7. For more details, please refer the link:
http://static.springsource.org/spring/docs/2.0.x/reference/transaction.html
NOTE: Sincere thanks to all the posts that I referred to when I implemented, experienced the above important points.
No comments:
Post a Comment