Update of /cvsroot/springnet/Spring.Net/doc/reference/src
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv28096
Modified Files:
ado.xml dbprovider.xml orm.xml transaction.xml
Log Message:
Improve documentation on transaction management - in particular mixed ado.net/nhibernate operations within the same transaction.
Index: transaction.xml
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/doc/reference/src/transaction.xml,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** transaction.xml 9 Aug 2007 06:30:17 -0000 1.19
--- transaction.xml 3 Oct 2007 14:38:35 -0000 1.20
***************
*** 199,204 ****
<para>This is primarily a 'SPI' (Service Provider Interface), although it
can be used programmatically. Note that in keeping with the Spring
! Framework's philosophy, IPlatformTransactionManager is an interface, and
! can thus be easily mocked or stubbed as necessary.
<interfacename>IPlatformTransactionManager</interfacename> implementations
are defined like any other object in the IoC container. The following
--- 199,204 ----
<para>This is primarily a 'SPI' (Service Provider Interface), although it
can be used programmatically. Note that in keeping with the Spring
! Framework's philosophy, <classname>IPlatformTransactionManager</classname>
! is an interface, and can thus be easily mocked or stubbed as necessary.
<interfacename>IPlatformTransactionManager</interfacename> implementations
are defined like any other object in the IoC container. The following
***************
*** 220,223 ****
--- 220,229 ----
local/distributed transaction manager from System.Transactions.</para>
</listitem>
+
+ <listitem>
+ <para><classname>HibernatePlatformTransactionManager</classname> -
+ local transaction manager for use with NHibernate or mixed
+ ADO.NET/NHibernate data access operations.</para>
+ </listitem>
</itemizedlist>
***************
*** 229,242 ****
ContextUtil.SetAbort(). Note you can use Spring's EnterpriseServices
exporter to have a EnterpriseService proxy created for your plain .NET
! object. Lastly, TxScopePlatformTransactionManager calls new
! TransactionScope(); .Complete(), Dispose(),
! Transaction.Current.Rollback(). Configuration properties for each
! transaction manager are specific to the data access technology used. Refer
! to the API docs for comprehensive information but the examples should give
! you a good basis for getting started.</para>
!
! <para>Note that other transaction managers, such as
! <classname>HibernateTransactionManager</classname>, are part of the
! Spring.NET modules project and available separately for download.</para>
<para>The <literal>GetTransaction(..)</literal> method returns a
--- 235,245 ----
ContextUtil.SetAbort(). Note you can use Spring's EnterpriseServices
exporter to have a EnterpriseService proxy created for your plain .NET
! object. TxScopePlatformTransactionManager calls new TransactionScope();
! .Complete(), Dispose(), Transaction.Current.Rollback(). Configuration
! properties for each transaction manager are specific to the data access
! technology used. Refer to the API docs for comprehensive information but
! the examples should give you a good basis for getting started. The
! HibernatePlatformTransactionManager is described more in the section
! <classname></classname>.</para>
<para>The <literal>GetTransaction(..)</literal> method returns a
***************
*** 307,312 ****
and then use Spring's
<classname>AdoPlatformTransactionManager</classname>, giving it a
! reference to the IDbProvider. For more information on the IDbProvider
! abstraction refer to the next chapter.</para>
<programlisting><objects xmlns='http://www.springframework.net'
--- 310,316 ----
and then use Spring's
<classname>AdoPlatformTransactionManager</classname>, giving it a
! reference to the <classname>IDbProvider</classname>. For more information
! on the <classname>IDbProvider</classname> abstraction refer to the next
! chapter.</para>
<programlisting><objects xmlns='http://www.springframework.net'
***************
*** 334,339 ****
</object></programlisting>
! <para>Similarly for the HibernateTransactionManager shown in the Spring
! NHibernate Modules documentation.</para>
<para>Note that in all these cases, application code will not need to
--- 338,344 ----
</object></programlisting>
! <para>Similarly for the HibernateTransactionManager as shown in the
! section on <link linkend="orm-tx-mgmt">ORM transaction
! management</link>.</para>
<para>Note that in all these cases, application code will not need to
Index: ado.xml
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/doc/reference/src/ado.xml,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** ado.xml 19 Sep 2007 21:24:44 -0000 1.16
--- ado.xml 3 Oct 2007 14:38:35 -0000 1.17
***************
*** 867,870 ****
--- 867,920 ----
<sect1>
+ <title>Transaction Management</title>
+
+ <para>The AdoTemplate is used in conjunction with an implementation of a
+ <classname>IPlatformTransactionManager</classname>, which is Spring's
+ portable transaction management API. This section gives a brief overview
+ of the transaction managers you can use with AdoTemplate and the details
+ of how you can retrieve the connection/transaction ADO.NET objects that
+ are bound to the thread when a transaction starts. Please refer to the
+ section <link linkend="key-abstractions">key abstractions</link> in the
+ chapter on transactions for more comprehensive introduction to transaction
+ management. </para>
+
+ <para>To use local transactions, those with only one transactional
+ resource (i.e. the database) you will typically use
+ <classname>AdoPlatformTransactionManager</classname>. If you need to mix
+ Hibernate and ADO.NET data access operations within the same local
+ transaction you should use
+ <classname>HibernatePlatformTransaction</classname> manager which is
+ described more in the section on <link linkend="orm-tx-mgmt">ORM
+ transaction management</link>. </para>
+
+ <para>While it is most common to use Spring's <link
+ linkend="transaction">transaction management features</link> to avoid the
+ low level management of ADO.NET connection and transaction objects, you
+ can retrieve the connection/transaction pair that was created at the start
+ of a transaction and bound to the current thread. This maybe useful for
+ some integration with other data access APIs. The can be done using the
+ utility class ConnectionUtils as shown below.</para>
+
+ <programlisting>IDbProvider dbProvider = DbProviderFactory.GetDbProvider("System.Data.SqlClient");
+ ConnectionTxPair connectionTxPairToUse = ConnectionUtils.GetConnectionTxPair(dbProvider);
+
+
+ IDbCommand command = DbProvider.CreateCommand();
+ command.Connection = connectionTxPairToUse.Connection;
+ command.Transaction = connectionTxPairToUse.Transaction;</programlisting>
+
+ <para>It is possible to provide a wrapper around the standard .NET
+ provider interfaces such that you can use the plain ADO.NET API in
+ conjunction with Spring's transaction management features. This
+ functionality will be available in a future release.</para>
+
+ <para>If you are using
+ <classname>ServiceDomainPlatformTransactionManager</classname> or
+ <classname>TxScopePlatformTransactionManager</classname> then you can
+ retrieve the currently executing trasaction object via the standard .NET
+ APIs.</para>
+ </sect1>
+
+ <sect1>
<title>Exception Translation</title>
Index: orm.xml
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/doc/reference/src/orm.xml,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** orm.xml 8 Aug 2007 18:41:03 -0000 1.11
--- orm.xml 3 Oct 2007 14:38:35 -0000 1.12
***************
*** 170,174 ****
</section>
! <section>
<title>Transaction Management</title>
--- 170,174 ----
</section>
! <section id="orm-tx-mgmt">
<title>Transaction Management</title>
***************
*** 184,196 ****
<para>The first strategy is encapsulated in the class
! <classname>Spring.Data..NHibernate.HibernateTransactionManager
</classname>in both the <literal>Spring.Data.NHibernate
</literal>namespace. This strategy is preferred when you are using a
single database. ADO.NET operations can also participate in the same
! transaction, either by using AdoTemplate, typical or by retrieving the
! ADO.NET connection/transaction object pair stored in thread local
! storage when the transaction begins. Refer to the documentation of
! Spring's ADO.NET framework for more information on retrieving and using
! the connection/transaction pair without using AdoTemplate.</para>
<para>The second strategy is to use the class
--- 184,219 ----
<para>The first strategy is encapsulated in the class
! <classname>Spring.Data.NHibernate.HibernateTransactionManager
</classname>in both the <literal>Spring.Data.NHibernate
</literal>namespace. This strategy is preferred when you are using a
single database. ADO.NET operations can also participate in the same
! transaction, either by using AdoTemplate or by retrieving the ADO.NET
! connection/transaction object pair stored in thread local storage when
! the transaction begins. Refer to the documentation of Spring's ADO.NET
! framework for more information on retrieving and using the
! connection/transaction pair without using AdoTemplate. You can use the
! HibernateTransactionManager and associated classes such as
! SessionFactory, HibernateTemplate directly as you would any third party
! API, however they are most commonly used through Spring's XML
! configuration file to gain the benefits of easy configuration for a
! particular runtime environment and as the basis for the configuration of
! a data access layer also configured using XML. An XML fragment showing
! the declaration of <classname>HibernateTransactionManager</classname> is
! shown below. </para>
!
! <programlisting> <object id="HibernateTransactionManager"
! type="Spring.Data.NHibernate.HibernateTransactionManager, Spring.Data.NHibernate">
!
! <property name="DbProvider" ref="DbProvider"/>
! <property name="SessionFactory" ref="MySessionFactory"/>
!
! </object></programlisting>
!
! <para>The important property of
! <classname>HibernateTransactionManager</classname> are the references to
! the DbProvider and the Hibernate ISessionFactory. For more information
! on the DbProvider, refer to the chapter <link
! linkend="dbprovider">DbProvider</link> and the following section on
! SessionFactory setup.</para>
<para>The second strategy is to use the class
Index: dbprovider.xml
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/doc/reference/src/dbprovider.xml,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** dbprovider.xml 9 Aug 2007 06:30:17 -0000 1.10
--- dbprovider.xml 3 Oct 2007 14:38:35 -0000 1.11
***************
*** 3,7 ****
<title>DbProvider</title>
! <section>
<title>Introduction</title>
--- 3,7 ----
<title>DbProvider</title>
! <section id="dbprovider-introduction">
<title>Introduction</title>
|