Solved

Programmatic transaction management vs Declarative transaction management

Posted on 2011-09-06
4
604 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
ID: 36493506


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
ID: 36493510
0
 
LVL 7

Author Comment

by:gudii9
ID: 36590028
>>>
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
ID: 36590063
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Starting to learn JAVA, 7 59
eclipse compiler vs Installed JREs option 3 73
Java Jpanels and Jframe 8 28
maven project error 5 47
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
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 …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

932 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

16 Experts available now in Live!

Get 1:1 Help Now