File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Application Frameworks and the fly likes does Spring handle JTA kind stuff ? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Application Frameworks » Other Application Frameworks
Reply Bookmark "does Spring handle JTA kind stuff ?" Watch "does Spring handle JTA kind stuff ?" New topic
Author

does Spring handle JTA kind stuff ?

ben oliver
Ranch Hand

Joined: Mar 28, 2006
Posts: 356
I have some JTA code and now I am thinking about using Spring --

1) can I keep JTA while I use Spring ?

2) Does Spring have any built-in features that handle things as JTA can handle (so I can get rid of JTA) ?
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
First off, I have to ask what are you are using JTA for? In my experiences, I find most people that are using JTA don't really even need it. It is one of those 1% solutions... the rest of the 99% of devleopers don't have real requirements for it.

That said... Spring's Transaction Management doesn't try to replace JTA but it does integrate nicely with it if that is what you need. You just declare a JtaTransactionManager:


Then proxy your DAOs (or whatever you are using) with TransactionProxyFactoryBean like this (notice with are wiring in the above transactionManager bean):


This example is of course not complete since Spring is expecting a bean definition "sampleDaoTarget" for your DAO implementation and a bean definition "transactionAttributeSource" to describe what propagation behavior to use for the transaction management. These definitions would look similar to:


What this basically does is tell Spring to mark every method in SampleDao as PROPAGATION_REQUIRED which behaves the same way as the REQUIRED transaction attribute in EJB. You can get a lot more granular with deciding what methods to apply what transaction attributes to using some of the other TransactionAttributeSource classes in Spring. You can even declare transaction support via Java 1.5 Annotations if that is of interest to you... I just tried to keep this example as basic as possible since Spring can be a bit overwelming to being with.
 
IntelliJ Java IDE
 
subject: does Spring handle JTA kind stuff ?
 
Threads others viewed
Using CMP & JPA in same application
JSF/Spring/Hibernate or JSF/Hibernate
Architecture planning with Spring and Appserver
Local transactions in application servers.
Hibernate and transaction management
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture