Springs Transaction Management - Understanding Spring Reference, Global/Local, Programmatic/Declarative - Two Questions?

You're over-thinking this a bit. The Spring API provides an abstract transaction model that has the same API and semantics regardless of which underlying transaction technology you use. In order to switch from one technology to another, you generally have to alter your Spring config, but the idea is that you never needs to to alter your business logic.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. The difference between declarative and programmatic transaction management is that with the former, you use annotations or XML config to say which bits of code are supposed to be transactional. With programmatic style, you specifically enclose transactional logic using method calls into the Spring API.

Note that if you use the declarative style, then Spring will wrap your code in generated logic which uses the programmatic style. The latter is simply a more explicit and low-level version of the former.It gives you more control, but it's more verbose.

Great answer, thank you! Just to make sure I understand: 1) When switching between different APIs AND/OR global/local transactions, I DONT have to change the CODE, but the CONFIGURATION. Correct?

And 2) I think I understand this without reasking :-) But Id like to know what happens if I use programmatic transaction management and want to switch my API (or between global/local transactions)? Then I do have to make changes in my CODE, or don't I? I also read that I have more options to define transactional behaviour when using decl.

Transman, but this must be incorrect, true? Thank you :-) – nano7 May 11 at 10:44 @nano7: 1) Correct The declarative/programmatic change means using different parts of the Spring API, so that involves a code change. 2) The programmatic API is independent of the underlying technology, just like the declarative style.

You get more flexibility when using programmatic style, but you very rarely need that flexibility. – skaffman May 11 at 10:46 Help, Im not sure if I understood this: a) -> When I use declarative API and I want to change for example from bernate(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 bernate(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 oh, ok.Sorry.So, no matter if I use programmatic/declarative, when I change the API (JTA, JDO, JDBC) or between global/local transactions, I have to make changes in the configuration, not in the code.

I think I got it. Thanks for your patience! :-) – nano7 May 11 at 11:04.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions