|
From: Juergen H. <ju...@in...> - 2005-01-26 20:52:22
|
FYI, I've added both a "useTransactionAwareDataSource" flag to LocalSessionFactoryBean and a TransactionAwareDataSourceConnectionFactory for OJB, as mentioned. Works nicely with Spring's DataSourceTransactionManager as transaction strategy, for example, or with OJB joining into HibernateTransactionManager transactions. Both Hibernate and OJB even apply Spring-managed transaction timeouts in such a scenario. As mentioned, this is essentially equivalent to pointing LocalSessionFactoryBean or OJB configuration to an explicit TransactionAwareDataSourceProxy definition. It's just more convenient to set up, and comes with full javadoc explaining why you would want to activate those options. This will be part of 1.1.4, to be released by the end of this week. Feel free to grab a nightly snapshot to give it an early try! Juergen -----Original Message----- From: spr...@li... [mailto:spr...@li...]On Behalf Of Juergen Hoeller Sent: Wednesday, January 26, 2005 4:42 PM To: spr...@li... Subject: Re: [Springframework-user] jta question The traditional way is to use JTA and point all of the tools to corresponding XA-aware DataSources, usually fetched from JNDI. However, there is an alternative: You can choose a local transaction strategy (like DataSourceTransactionManager or HibernateTransactionManager) and make all your tools participate in those transactions. This will work as long as you're just accessing a single database. Essentially, you need point all O/R mappers that are supposed to participate in such transactions to a Spring TransactionAwareDataSourceProxy, which in turn delegates to the target DataSource. They will automatically receive transactional JDBC connections managed by Spring then, which is usually enough to make them participate in Spring-managed transactions. In the case of OJB, the repository file needs to point to a Spring bean name as jcd-alias, with that bean being the TransactionAwareDataSourceProxy definition in the Spring context. A freshly opened OJB PersistenceBroker will then automatically use the transactional JDBC connection, as managed by Spring. Such OJB setup can, for example, be combined with HibernateTransactionManager as transaction strategy, or with JdoTransactionManager or DataSourceTransactionMannger. OJB is the least demanding in terms of transaction strategy, so it's recommendable to use Hibernate as main transaction strategy, with OJB joining in. On this occasion, I consider adding a "useTransactionAwareDataSource" flag to LocalSessionFactoryBean, analogous to what SqlMapClientFactoryBean already has. It would be off by default, but allow Hibernate access code to participate in JDO transactions (or the like) through a simple flag, completely without JTA. Analogously, I intend to add a TransactionAwareDataSourceConnectionFactory for OJB, as a subclass of LocalDataSourceConnectionFactory that automatically uses a TransactionAwareDataSourceProxy for all target DataSources accessed through OJB. Of course, that would just be a convenience, equivalent to explicit TransactionAwareDataSourceProxy definitions in the Spring context. Juergen -----Original Message----- From: spr...@li... [mailto:spr...@li...]On Behalf Of Hal Arnold Sent: Tuesday, January 25, 2005 6:42 PM To: spr...@li... Subject: [Springframework-user] jta question All, Forgive me if this question has been asked/answered. I'm trying to get some old code written with OJB to be used/useful (read, don't refactor yet) in the same transaction as new code that is under Hibernate. From what I've read, I should go down the JTA path. (Is this true?) I'm looking at the readme.txt in the petclinic example and find: "All data access strategies can work with JTA for transaction management, by activating the JtaTransactionManager and a JndiObjectFactoryBean that refers to a transactional container DataSource." Does this mean that you can't use JTA without resorting to the container? If not, can someone point me to some code that shows how one would fire up a JtaTransactionManager without resorting to the "container(s) datasource" /hba ------------------------------------------------------- This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl _______________________________________________ Springframework-user mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-user ------------------------------------------------------- This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl _______________________________________________ Springframework-user mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-user |