|
Re: Is Spring transaction management worthusing?: msg#00527java.springframework.user
Brandon, I think it's pretty clear from our docs and samples that Spring's JtaTransactionManager itself works just nicely in a container-independent fashion - in typical usage scenarios where you could use a plain JTA javax.transaction.UserTransaction too. We have always clarified this when a corresponding question has popped up on the forums. As Dmitriy has outlined, you just need container-specific configuration for more advanced usage, namely transaction suspension and Hibernate cache completion callbacks. The simple reason for this is that you need the JTA javax.transaction.TransactionManager to suspend/resume transactions and register transaction synchronizations; the UserTransaction interface does not support that functionality. Unfortunately, J2EE does not specify how to access the JTA TransactionManager, just the common JNDI location of the JTA UserTransaction - so the lookup of the JTA TransactionManager has to be container-specific. This is the case with Hibernate (see TransactionManagerLookup), this is the case with Spring, this is the case with any such tool. So for typical usages, simple declare Spring's JtaTransactionManager without any properties. Just for transaction suspension, specify a "transactionManagerName" (JNDI location of the JTA TransactionManager) or a "transactionManager" reference (from JndiObjectFactoryBean, to centrally define the JNDI location; or from a special lookup strategy, like JotmFactoryBean or WebSphereTransactionManagerFactoryBean). ----- For Hibernate cache completion callbacks with JTA, you need to specify a corresponding TransactionManagerLookup in the Hibernate properties. As an alternative, Spring allows you to pass a JTA TransactionManager into LocalSessionFactoryBean's "jtaTransactionManager" property, to reuse a centrally defined TransactionManager reference that can be shared with JtaTransactionManager's "transactionManager" property. Note that you'll also get proper Hibernate cache completion callbacks without such a container-specific TransactionManagerLookup, as long as you use Spring's transaction management - because Spring has its own transaction synchronization mechanism. So even for proper Hibernate callbacks with Spring, there is typically no need for container-specific JTA configuration; a plain JtaTransactionManager definition is fine. That said, there is an issue with WebLogic/WebSphere and Hibernate, which is also what keeps popping up on our forums: Those containers have very rigid JTA implementations that don't allow any access to a transactional JDBC Connection after transaction completion. Because of this, Spring's standard Hibernate cache completion callback causes a warning in the logs; an additional container-specific Hibernate TransactionManagerLookup avoids this. ----- All things considered, to the best of my knowledge, Spring's JTA support is as strong as can be. It even includes special support for Hibernate/JTA integration, which addresses typical Hibernate issues. Spring cannot offer more than it does already, as JTA simply doesn't specify more functionality. It cannot simplify JTA configuration either, as the remaining limits are caused by JTA itself. In particular, Spring's transaction management offers all 6 propagation behavior types that EJB CMT defines (REQUIRED, REQUIRES_NEW, etc). In the case of JTA, REQUIRES_NEW and NOT_SUPPORTED can just be offered if the javax.transaction.TransactionManager is accessible, which requires a container-specific lookup - a J2EE/JTA issue that is not caused by Spring, and faced by all tools that work with JTA in a J2EE environment. Side note: Spring's other transaction strategies, namely DataSourceTransactionManager, HibernateTransactionManager and JdoTransactionManager, offer all 6 propagation behavior types too - without any container-specific configuration. Furthermore, the former two also offer per-transaction isolation levels, which is a concept not supported by JTA in the first place. Some transaction strategies support "read-only transactions" too, for example HibernateTransactionManager. ----- Please, before you quote anonymous sources that say that "JTA support is poor" and speculate about problems "when containers upgrade" - without specific problems, and on a public user forum of the product that you're questioning -, spend a few minutes checking your facts. A look into the docs/javadocs - or a detailed read of answers to those forum questions you referred to - would have revealed that those assumptions are obviously wrong. So, now that we've removed that obstacle: If you've got any further questions regarding Spring's transaction support (*after* a look at the docs), feel free to ask me: be it about usage patterns, implementation internals, issues with specific persistence tools, or issues with specific J2EE containers. I'll also be happy to clarify any issues regarding Spring's support for iBATIS SQL Maps, which is obviously of interest to you :-) Juergen ________________________________ Von: springframework-user-admin@xxxxxxxxxxxxxxxxxxxxx im Auftrag von Dmitriy Kopylenko Gesendet: Sa 29.05.2004 05:44 An: springframework-user@xxxxxxxxxxxxxxxxxxxxx Betreff: Re: [Springframework-user] Is Spring transaction management worthusing? Brandon, thanks for your reply. Let me briefly say that Spring provides completely generic implementation of PlatformTransactionManager namely JtaTransactionManager which handles most of the use cases for generic J2EE global transactions such as distributed transactions and managing transactions on J2EE connector (JCA resource adapter). In order to support transaction suspension (REQUIRES_NEW, NOT_SUPPORTED), Spring needs to get hold of JTA TransactionManager which is an internal JTA object and its location is not specified by J2EE spec. and is individual for each J2EE container. Spring provides two FactoryBean implementations for JOTM and WebSphere to obtain the JtaTransactionManager for respective JTA implementations, as static accessor methods are required to get hold of TransactionManager for both JOTM and WebSphere... I'm not sure about a potential problem with containers upgrade. I'll let Juergen, Rod and others comment on this. Regards, Dmitriy. Brandon Goodin wrote: I'm just trying to find out if there are any serious problems with Transaction Management. Looking into the archives it seems the chief complaint is that spring has to provide specific container support for JTA Transaction Management. That could pose a problem as containers upgrade. Projects using spring would need to make sure that Spring has support for their container before proceeding with a point upgrade. This is in line with what I heard from another source. Is this an accurate portrayal? Brandon Goodin ________________________________ From: springframework-user-admin@xxxxxxxxxxxxxxxxxxxxx [mailto:springframework-user-admin@xxxxxxxxxxxxxxxxxxxxx] On Behalf Of Dmitriy Kopylenko Sent: Friday, May 28, 2004 8:04 PM To: springframework-user@xxxxxxxxxxxxxxxxxxxxx Subject: Re: [Springframework-user] Is Spring transaction management worthusing? Brandon, I'm sorry, but from your email it's not clear what you mean. You said: "in general I've heard that the JTA support is poor" I just what to find out from whom you heard that statement? In general I could tell you one thing - Spring's JTA support is not poor at all ;-) Regards, Dmitriy. Brandon Goodin wrote: Why are you asking me a question that I have already answered? Read my email and you may find the answer to your question. ;-) Brandon ________________________________ From: springframework-user-admin@xxxxxxxxxxxxxxxxxxxxx [mailto:springframework-user-admin@xxxxxxxxxxxxxxxxxxxxx] On Behalf Of Dmitriy Kopylenko Sent: Friday, May 28, 2004 7:34 PM To: springframework-user@xxxxxxxxxxxxxxxxxxxxx Subject: Re: [Springframework-user] Is Spring transaction management worthusing? I'm just curious - where did you hear that "the JTA support is poor" and what are the specific areas of this "poor support"? Dmitriy. Brandon Goodin wrote: Specifically, I have nothing. But, in general I've heard that the JTA support is poor. I'm just curious if anyone can give me a clear blow for blow on where the Transaction capabilities are strong and where they need some work. Brandon Goodin -----Original Message----- From: springframework-user-admin@xxxxxxxxxxxxxxxxxxxxx [mailto:springframework-user-admin@xxxxxxxxxxxxxxxxxxxxx] On Behalf Of Nadeem Bitar Sent: Friday, May 28, 2004 5:30 PM To: springframework-user@xxxxxxxxxxxxxxxxxxxxx Subject: Re: [Springframework-user] Is Spring transaction management worthusing? On ?, 2004-05-28 at 18:11 -0700, Brandon Goodin wrote: I've heard that there are issues with the Spring transaction management. Can someone explain to me the pros and cons of Spring's management of transactions? Which issues? because I having been using it for a year without any problem. Brandon Goodin ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id66&op=click _______________________________________________ Springframework-user mailing list Springframework-user@xxxxxxxxxxxxxxxxxxxxx https://lists.sourceforge.net/lists/listinfo/springframework-user ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click _______________________________________________ Springframework-user mailing list Springframework-user@xxxxxxxxxxxxxxxxxxxxx https://lists.sourceforge.net/lists/listinfo/springframework-user ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id?66&op=click
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: looking up local or remote objects w/o changing client code, Bruce Snyder |
|---|---|
| Next by Date: | RE: Is Spring transaction management worthusing?, Brandon Goodin |
| Previous by Thread: | Is Spring transaction management worth using?, Brandon Goodin |
| Next by Thread: | RE: Is Spring transaction management worthusing?, Brandon Goodin |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |