From: Michael D. <mik...@us...> - 2005-04-12 02:45:50
|
Update of /cvsroot/nhibernate/nhibernate/doc/reference/en/modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13578/nhibernate/doc/reference/en/modules Modified Files: example_parentchild.xml persistent_classes.xml Log Message: more work on doco Index: example_parentchild.xml =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/doc/reference/en/modules/example_parentchild.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** example_parentchild.xml 11 Apr 2005 03:45:37 -0000 1.2 --- example_parentchild.xml 12 Apr 2005 02:45:38 -0000 1.3 *************** *** 270,274 **** <sect1 id="example-parentchild-update"> <title>Using cascading <literal>update()</literal></title> ! <para></para> </sect1> </chapter> \ No newline at end of file --- 270,321 ---- <sect1 id="example-parentchild-update"> <title>Using cascading <literal>update()</literal></title> ! <para> ! Suppose we loaded up a <literal>Parent</literal> in one <literal>ISession</literal>, mode some changes in a UI ! action and wish to persist these changes in a new ISession (by calling <literal>Update()</literal>). The ! <literal>Parent</literal> will contain a collection of children and, since cascading update is enabled, NHibernate ! needs to know which children are newly instantiated and which represent existing rows in the database. Lets assume ! that both <literal>Parent</literal> and <literal>Child</literal> have (synthetic) identifier properties of type ! <literal>System.Int32</literal>. NHibernate will use the identifier property value to determine which of the ! children are new. ! <!-- TODO: add comments about version/timestamp when the build is released --> ! </para> ! <para> ! The <literal>unsaved-value</literal> attribute is used to specify the identifier value of a newly instantiated ! instance. <literal>unsaved-value</literal> defaults to "null", which is not a sensible default in the .net with ! ValueTypes, so you need to specify the unsaved-value ! </para> ! <programlisting><![CDATA[<id name="Id" type="Int64" unsaved-value="0" ]]></programlisting> ! <para> ! for the <literal>Child</literal> mapping. <!-- ! TODO: not implemented in production build yet ! (There is also an <literal>unsaved-value</literal> attribute ! for version and timestamp property mappings.)--> ! </para> ! <para> ! The following code will update <literal>parent</literal> and <literal>child</literal> and insert ! <literal>newChild</literal>. ! </para> ! ! <programlisting><![CDATA[//parent and child were both loaded in a previous session ! parent.AddChild( child ); ! Child newChild = new Child(); ! parent.AddChild( newChild ); ! session.Update( parent ); ! session.Flush();]]></programlisting> ! ! <para> ! <!-- TODO: discuss use of unsaved-value with version and timestamp --> ! </para> ! </sect1> ! ! <sect1 id="example-parentchild-conclusion"> ! <title>Conclusion</title> ! <para> ! There is quite a bit to digest here and it might look confusing first time around. However, in practice, it ! all works out quite nicely. Most NHibernate applications use the parent/child pattern in many places. ! </para> ! <para> ! <!-- TODO: describe composite-element --> ! </para> </sect1> </chapter> \ No newline at end of file Index: persistent_classes.xml =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/doc/reference/en/modules/persistent_classes.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** persistent_classes.xml 8 Apr 2005 19:23:35 -0000 1.1 --- persistent_classes.xml 12 Apr 2005 02:45:38 -0000 1.2 *************** *** 0 **** --- 1,55 ---- + <!-- + before committing make sure to comment out the DOCTYPE + It is in here to get intellisense with XMLSpy. The + HomeEdition is a free download. + + --> + <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" + "../../support/docbook-dtd/docbookx.dtd"> + + <chapter id="persistent-classes"> + + <title>Persistent Classes</title> + <para></para> + + <sect1 id="persistent-classes-poco"> + <title>A simple POCO example</title> + <para></para> + <sect2 id="persistent-classes-poco-accessors"> + <title>Declare getters and setters for persistent fields (optional)</title> + <para></para> + </sect2> + <sect2 id="persistent-classes-poco-constructor"> + <title>Implement a default constructor</title> + <para></para> + </sect2> + <sect2 id="persistent-classes-poco-identifier"> + <title>Provide an identifier property (optional)</title> + <para></para> + </sect2> + <sect2 id="persistent-classes-poco-sealed"> + <title>Prefer non-sealed classes (optional)</title> + <para></para> + </sect2> + </sect1> + <sect1 id="persistent-classes-inheritance"> + <title>Implementing inheritence</title> + <para></para> + </sect1> + <sect1 id="persistent-classes-equalshashcode"> + <title>Implementing <literal>Equals()</literal> and <literal>GetHashCode()</literal></title> + <para></para> + </sect1> + <sect1 id="persistent-classes-lifecycle"> + <title>Lifecycle Callbacks</title> + <para></para> + </sect1> + <sect1 id="persistent-classes-validatable"> + <title>Validatable callback</title> + <para></para> + </sect1> + <sect1 id="persistent-classes-attribute"> + <title>Using Attributes instead of XML</title> + <para></para> + </sect1> + </chapter> \ No newline at end of file |