From: <fab...@us...> - 2009-07-14 13:11:23
|
Revision: 4611 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4611&view=rev Author: fabiomaulo Date: 2009-07-14 13:11:16 +0000 (Tue, 14 Jul 2009) Log Message: ----------- Added natural-id to doc Modified Paths: -------------- branches/2.1.x/nhibernate/doc/reference/modules/basic_mapping.xml Modified: branches/2.1.x/nhibernate/doc/reference/modules/basic_mapping.xml =================================================================== --- branches/2.1.x/nhibernate/doc/reference/modules/basic_mapping.xml 2009-07-14 01:36:03 UTC (rev 4610) +++ branches/2.1.x/nhibernate/doc/reference/modules/basic_mapping.xml 2009-07-14 13:11:16 UTC (rev 4611) @@ -1656,7 +1656,45 @@ <programlisting><![CDATA[<one-to-one name="Employee" class="Employee" property-ref="Person"/>]]></programlisting> </sect2> - + + <sect2 id="mapping-declaration-naturalid"> + <title>natural-id</title> + + <programlisting><![CDATA[<natural-id mutable="true|false"/> + <property ... /> + <many-to-one ... /> + ...... +</natural-id>]]></programlisting> + + <para> + Even though we recommend the use of surrogate keys as primary keys, you should still try + to identify natural keys for all entities. A natural key is a property or combination of + properties that is unique and non-null. If it is also immutable, even better. Map the + properties of the natural key inside the <literal><natural-id></literal> element. + Hibernate will generate the necessary unique key and nullability constraints, and your + mapping will be more self-documenting. + </para> + + <para> + We strongly recommend that you implement <literal>Equals()</literal> and + <literal>GetHashCode()</literal> to compare the natural key properties of the entity. + </para> + + <para> + This mapping is not intended for use with entities with natural primary keys. + </para> + + <itemizedlist spacing="compact"> + <listitem> + <para> + <literal>mutable</literal> (optional, defaults to <literal>false</literal>): + By default, natural identifier properties as assumed to be immutable (constant). + </para> + </listitem> + </itemizedlist> + + </sect2> + <sect2 id="mapping-declaration-component"> <title>component, dynamic-component</title> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-07-14 18:59:33
|
Revision: 4629 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4629&view=rev Author: fabiomaulo Date: 2009-07-14 18:59:32 +0000 (Tue, 14 Jul 2009) Log Message: ----------- Docs typedef Modified Paths: -------------- branches/2.1.x/nhibernate/doc/reference/modules/basic_mapping.xml Modified: branches/2.1.x/nhibernate/doc/reference/modules/basic_mapping.xml =================================================================== --- branches/2.1.x/nhibernate/doc/reference/modules/basic_mapping.xml 2009-07-14 18:51:14 UTC (rev 4628) +++ branches/2.1.x/nhibernate/doc/reference/modules/basic_mapping.xml 2009-07-14 18:59:32 UTC (rev 4629) @@ -2499,8 +2499,25 @@ The <literal>IUserType</literal> can now retrieve the value for the parameter named <literal>default</literal> from the <literal>IDictionary</literal> object passed to it. </para> - <para> + If you use a certain <literal>UserType</literal> very often, it may be useful to define a + shorter name for it. You can do this using the <literal><typedef></literal> element. + Typedefs assign a name to a custom type, and may also contain a list of default + parameter values if the type is parameterized. + </para> + + <programlisting><![CDATA[<typedef class="MyCompany.UserTypes.DefaultValueIntegerType" name="default_zero"> + <param name="default">0</param> +</typedef>]]></programlisting> + + <programlisting><![CDATA[<property name="priority" type="default_zero"/>]]></programlisting> + + <para> + It is also possible to override the parameters supplied in a typedef on a case-by-case basis + by using type parameters on the property mapping. + </para> + + <para> Even though NHibernate's rich range of built-in types and support for components means you will very rarely <emphasis>need</emphasis> to use a custom type, it is nevertheless considered good form to use custom types for (non-entity) classes that occur frequently This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |