Solved

Programmatic transaction management vs Declarative transaction management

Posted on 2011-09-06
4
720 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Application launch issue with Apache Tomcat 5 62
hibernate insert example 13 34
JavaFX TableView not displaying correctly 3 55
Glassfish admin console not working 1 32
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
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.

808 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