[Springnet-commits] Spring.Net/doc/reference/src orm.xml, 1.13, 1.14
Brought to you by:
aseovic,
markpollack
From: Erich E. <oak...@us...> - 2007-12-06 19:31:26
|
Update of /cvsroot/springnet/Spring.Net/doc/reference/src In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv23017 Modified Files: orm.xml Log Message: clarified OSIV's FlushMode.NEVER strategy Index: orm.xml =================================================================== RCS file: /cvsroot/springnet/Spring.Net/doc/reference/src/orm.xml,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** orm.xml 6 Dec 2007 06:26:31 -0000 1.13 --- orm.xml 6 Dec 2007 19:31:17 -0000 1.14 *************** *** 1,3 **** ! <?xml version="1.0" encoding="UTF-8"?> <chapter id="orm"> <title>Object Relational Mapping (ORM) data access</title> --- 1,3 ---- ! <?xml version="1.0" encoding="UTF-8"?> <chapter id="orm"> <title>Object Relational Mapping (ORM) data access</title> *************** *** 228,236 **** will be opened for each operation. The exception to this rule is when using the <classname>OpenSessionInViewModule</classname> in a web ! application in single session mode. In this case the session will be ! created on the start of the web request and closed on the end of the ! request. Note that the session's flushmode will be set to ! FlushMode.NEVER at the start of the request. If a non-readonly ! transaction is performed, then during the scope of that transaction processing the flushmode will be changed to AUTO, and then set back to NEVER at the end of the transaction scope so that any changes to objects --- 228,236 ---- will be opened for each operation. The exception to this rule is when using the <classname>OpenSessionInViewModule</classname> in a web ! application in single session mode (see <xref linkend="orm-hibernate-web"/>). ! In this case the session will be created on the start of the web request and ! closed on the end of the request. Note that the session's flushmode will ! be set to <literal>FlushMode.NEVER</literal> at the start of the request. ! If a non-readonly transaction is performed, then during the scope of that transaction processing the flushmode will be changed to AUTO, and then set back to NEVER at the end of the transaction scope so that any changes to objects *************** *** 331,340 **** </objects></programlisting> ! <programlisting>public class HibernateCustomerDao : ICustomerDao { private HibernateTemplate hibernateTemplate; ! public ISessionFactory SessionFactory { set { hibernateTemplate = new HibernateTemplate(value); } --- 331,340 ---- </objects></programlisting> ! <para/> <programlisting>public class HibernateCustomerDao : ICustomerDao { private HibernateTemplate hibernateTemplate; ! public ISessionFactory SessionFactory { set { hibernateTemplate = new HibernateTemplate(value); } *************** *** 360,364 **** private HibernateTemplate hibernateTemplate; ! public ISessionFactory SessionFactory { set { hibernateTemplate = new HibernateTemplate(value); } --- 360,364 ---- private HibernateTemplate hibernateTemplate; ! public ISessionFactory SessionFactory { set { hibernateTemplate = new HibernateTemplate(value); } *************** *** 472,476 **** private SessionFactory sessionFactory; ! public ISessionFactory SessionFactory { get { return sessionFactory; } --- 472,476 ---- private SessionFactory sessionFactory; ! public ISessionFactory SessionFactory { get { return sessionFactory; } *************** *** 491,495 **** private ISessionFactory sessionFactory; ! public ISessionFactory SessionFactory { set { sessionFactory = value; } --- 491,495 ---- private ISessionFactory sessionFactory; ! public ISessionFactory SessionFactory { set { sessionFactory = value; } *************** *** 533,537 **** <programlisting><object id="sessionFactory" type="Spring.Data.NHibernate.LocalSessionFactoryObject, Spring.Data.NHibernate12"> ! <emphasis role="bold"><property name="ExposeTransactionAwareSessionFactory" value="true" /></emphasis> --- 533,537 ---- <programlisting><object id="sessionFactory" type="Spring.Data.NHibernate.LocalSessionFactoryObject, Spring.Data.NHibernate12"> ! <emphasis role="bold"><property name="ExposeTransactionAwareSessionFactory" value="true" /></emphasis> *************** *** 551,555 **** <!-- other dictionary entries omitted --> ! <emphasis role="bold"><entry key="hibernate.current_session_context_class" value="Spring.Data.NHibernate.SpringSessionContext, Spring.Data.NHibernate12"/></emphasis> --- 551,555 ---- <!-- other dictionary entries omitted --> ! <emphasis role="bold"><entry key="hibernate.current_session_context_class" value="Spring.Data.NHibernate.SpringSessionContext, Spring.Data.NHibernate12"/></emphasis> *************** *** 615,621 **** private ICustomerDao customerDao; ! private IOrderDao orderDao; ! private IShippingService shippingService; --- 615,621 ---- private ICustomerDao customerDao; ! private IOrderDao orderDao; ! private IShippingService shippingService; *************** *** 674,678 **** xmlns:tx="http://www.springframework.net/schema/tx" xsi:schemaLocation="http://www.springframework.net http://www.springframework.net/schema/objects/spring-objects.xsd ! http://www.springframework.net/schema/tx http://www.springframework.net/schema/tx/spring-tx-1.1.xsd"> --- 674,678 ---- xmlns:tx="http://www.springframework.net/schema/tx" xsi:schemaLocation="http://www.springframework.net http://www.springframework.net/schema/objects/spring-objects.xsd ! http://www.springframework.net/schema/tx http://www.springframework.net/schema/tx/spring-tx-1.1.xsd"> *************** *** 704,708 **** <programlisting>public class FulfillmentService : IFulfillmentService { ! // fields and properties for dao object omitted, see above --- 704,708 ---- <programlisting>public class FulfillmentService : IFulfillmentService { ! // fields and properties for dao object omitted, see above *************** *** 713,733 **** //Find all orders for customer Customer customer = CustomerDao.FindById(customerId); ! foreach (Order order in customer.Orders) { //Validate Order Validate(order); ! //Ship with external shipping service ShippingService.ShipOrder(order); ! //Update shipping date order.ShippedDate = DateTime.Now; ! //Update shipment date OrderDao.SaveOrUpdate(order); ! //Other operations...Decrease product quantity... etc ! } } --- 713,733 ---- //Find all orders for customer Customer customer = CustomerDao.FindById(customerId); ! foreach (Order order in customer.Orders) { //Validate Order Validate(order); ! //Ship with external shipping service ShippingService.ShipOrder(order); ! //Update shipping date order.ShippedDate = DateTime.Now; ! //Update shipment date OrderDao.SaveOrUpdate(order); ! //Other operations...Decrease product quantity... etc ! } } *************** *** 740,744 **** <programlisting> <object id="TxProxyConfigurationTemplate" abstract="true" type="Spring.Transaction.Interceptor.TransactionProxyFactoryObject, Spring.Data"> ! <property name="PlatformTransactionManager" ref="HibernateTransactionManager"/> --- 740,744 ---- <programlisting> <object id="TxProxyConfigurationTemplate" abstract="true" type="Spring.Transaction.Interceptor.TransactionProxyFactoryObject, Spring.Data"> ! <property name="PlatformTransactionManager" ref="HibernateTransactionManager"/> *************** *** 799,803 **** </section> ! <section> <title>Web Session Management</title> --- 799,803 ---- </section> ! <section id="orm-hibernate-web"> <title>Web Session Management</title> *************** *** 839,842 **** --- 839,854 ---- be unique across all sessions. Problems can arise if the same object is associated with more than one hibernate session.</para> + + <important><para>By default, OSIV applies <literal>FlushMode.NEVER</literal> on every session it creates. + This is because if OSIV flushed pending changes during "EndRequest" and an error occurs, all response + has already been sent to the client. There would be no way of telling the client about the + error.</para> + <para> + By default this means you MUST explicitely demarcate transaction boundaries + around non-readonly statements when using OSIV. + For configuring transactions see <xref linkend="orm-hibernate-tx-declarative" /> or + the <command>Spring.Data.NHibernate.Northwind</command> example application. + </para> + </important> </section> *************** *** 850,854 **** <programlisting>using (new SessionScope()) { ! ... do multiple operations with a single session, possibly in multiple transactions. }</programlisting> --- 862,866 ---- <programlisting>using (new SessionScope()) { ! ... do multiple operations with a single session, possibly in multiple transactions. }</programlisting> |