Solved

Programmatic transaction management vs Declarative transaction management

Posted on 2011-09-06
4
798 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
fibonacci ten numbers 4 54
running on tomcat not jboss eap 7.0 3 32
jmeter usage 4 38
Java class and jar 3 42
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

733 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