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


im working spring framework 3.0.5 , hibernate framework , im starting use springs transactionmanagement. have questions, understand how springs transactionmanagement works.

1)

i read things in spring reference:

a) consistent programming model across different transaction apis such java transaction api (jta), jdbc, hibernate, java persistence api (jpa), , java data objects (jdo).

b) spring resolves disadvantages of global , local transactions. enables application developers use consistent programming model in environment. write code once, , can benefit different transaction management strategies in different environments.

c) gone days when alternative using ejb cmt or jta write code local transactions such on jdbc connections, , face hefty rework if need code run within global, container-managed transactions. spring framework, of bean definitions in configuration file, rather code, need change.

from a) understand can use apis spring without changing code

from b) understand can use global or local transactions *without changing code

from c) understand while switching between different apis , global/local transactions need change code

now wonder correct?

=> need change code? when switching between different apis? when switching between local , global transactions? (or maybe depend on prorgammatic , declarative transaction management?)

2)

i got additional question: wonder the use of programmatic transaction management is? everywhere read declarative transactionmanagement recommended

i read in spring reference too:

d) programmatic transaction management, developers work spring framework transaction abstraction, can run on underlying transaction infrastructure. preferred declarative model, developers typically write little or no code related transaction management, , hence not depend on spring framework transaction api, or other transaction api.

from d) understand: programmatic transaction management can use underlying transaction infrastructure... means what? different apis mentioned above?

and: declarative not depend on api

=> isnt same? when can use underlying api, not depend on api. not understand this.

where difference? know declarative transaction management more lightweight, have not start transaction self , catch exception , handle , on. use of programmatic transaction management then?

thank answering! :-)

  1. you're over-thinking bit. spring api provides abstract transaction model has same api , semantics regardless of underlying transaction technology use. in order switch 1 technology another, have alter spring config, idea never needs to alter business logic. whether you're using local, in-vm jdbc transactions or distributed, two-phase-commit xa jpa-style transactions, api usage within spring code same. configuration changes.

  2. the difference between declarative , programmatic transaction management former, use annotations or xml config bits of code supposed transactional. programmatic style, enclose transactional logic using method calls spring api. note if use declarative style, spring wrap code in generated logic uses programmatic style. latter more explicit , low-level version of former. gives more control, it's more verbose.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -