[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Programmatic transaction management vs Declarative transaction management

Posted on 2011-09-06
4
Medium Priority
?
1,197 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:
Gurvinder Pal Singh earned 1000 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 1000 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

Independent Software Vendors: 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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Suggested Courses

650 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