Solved

Programmatic transaction management vs Declarative transaction management

Posted on 2011-09-06
4
560 Views
Last Modified: 2012-05-12
i would liek to know about
Programmatic transaction management.
Declarative transaction management.

When, how, where to use each of them. Advantages, disadvantages of them, practical implementations of them. I am not clear on this concept. thanks in advance
0
Comment
Question by:gudii9
  • 2
4 Comments
 
LVL 47

Expert Comment

by:for_yan
Comment Utility


from here:
http://monstersandwich.blogspot.com/2010/04/spring-transactions-sample-applications.html

(also read some examples in the same articles - in the beginning)

Thhis is the conclusion:

Programmatic or declarative transaction management?

    "Programmatic transaction management is usually a good idea only if you have a small number of transactional operations. For example, if you have a web application that require transactions only for certain update operations, you may not want to set up transactional proxies using Spring or any other technology. In this case, using the TransactionTemplate may be a good approach. Being able to set the transaction name explicitly is also something that can only be done using the programmatic approach to transaction management.


    On the other hand, if your application has numerous transactional operations, declarative transaction management is usually worthwhile. It keeps transaction management out of business logic, and is not difficult to configure. When using the Spring Framework, rather than EJB CMT, the configuration cost of declarative transaction management is greatly reduced."
0
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 250 total points
Comment Utility
0
 
LVL 7

Author Comment

by:gudii9
Comment Utility
>>>
So whether you're using local, in-VM JDBC transactions or fully distributed, two-phase-commit XA JPA-style transactions, the API usage within your Spring code is the same. Only the configuration changes.

>>> in-VM JDBC transactions or fully distributed, two-phase-commit XA JPA-style transactions
what it mean by in-vm, fully distribured,two-phase-commit XA JPA.




>>>global/local transactions

what are the differences between these

>>>Help, Im not sure if I understood this: a) -> When I use declarative API and I want to change for example from Hibernate(with JDBC) to JTA, I DONT have to change the CODE, but to change the CONFIGURATION. b) -> When I use programmatic API and I want to change for example from Hibernate(with JDBC) to JTA, I HAVE to CHANGE the CODE AND the CONFIGURATION => SO the disadvantage of using programmatic API is that one has to made changes to the CODE when switching between JTA, JDO, JPA, JDBC.... and so on... correct? :-( Thank you! :-) – nano7 May 11 at 10:54
 @nano7: No: The programmatic API is independent of the underlying technology, just like the declarative API is. – skaffman May 11 at 10:59


I am not clear on above as well. Does it nean both approaches does not need code change except configuation change? Please advise



0
 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 250 total points
Comment Utility
No, as a rule when you need to make changes  declarative transaction managemnt will require to change configuation files
and progarmmatic management will require to change the code

However one can imagine such situations whne the changes you need to make
are not covered by options available in declarative management - then you'll still have to go the code.

To put it very simple -as always in this case - declarative makes it easier to switch between some common
options, programmatically it requires more work (say, compilation, etc) but gives you more flexibilty
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now