Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update documentation for new generator mapping (NH-1007)

  • Loading branch information...
commit 8c8558587acd373ea09cc2cafa18ecab2e9ebf84 1 parent 5b4e794
@julian-maughan julian-maughan authored
View
18 doc/reference/modules/basic_mapping.xml
@@ -498,10 +498,13 @@
<title>generator</title>
<para>
- The required <literal>&lt;generator&gt;</literal> child element names a .NET class used
- to generate unique identifiers for instances of the persistent class. If any parameters
- are required to configure or initialize the generator instance, they are passed using the
- <literal>&lt;param&gt;</literal> element.
+ The required <literal>generator</literal> names a .NET class used to generate unique identifiers
+ for instances of the persistent class.
+ </para>
+ <para>
+ The generator can be declared using the <literal>&lt;generator&gt;</literal> child element. If
+ any parameters are required to configure or initialize the generator instance, they are passed
+ using <literal>&lt;param&gt;</literal> elements.
</para>
<programlisting><![CDATA[<id name="Id" type="Int64" column="uid" unsaved-value="0">
@@ -512,6 +515,13 @@
</id>]]></programlisting>
<para>
+ If no parameters are required, the generator can be declared using a <literal>generator</literal>
+ attribute directly on the <literal>&lt;id&gt;</literal> element, as follows:
+ </para>
+
+ <programlisting><![CDATA[<id name="Id" type="Int64" column="uid" unsaved-value="0" generator="native" />]]></programlisting>
+
+ <para>
All generators implement the interface <literal>NHibernate.Id.IIdentifierGenerator</literal>.
This is a very simple interface; some applications may choose to provide their own specialized
implementations. However, NHibernate provides a range of built-in implementations. There are shortcut
View
13 doc/reference/modules/example_mappings.xml
@@ -155,9 +155,8 @@ create sequence employer_id_seq]]></programlisting>
<class name="Work" table="works" discriminator-value="W">
- <id name="Id" column="id">
- <generator class="native"/>
- </id>
+ <id name="Id" column="id" generator="native" />
+
<discriminator column="type" type="character"/>
<property name="Title"/>
@@ -286,9 +285,7 @@ alter table author_work
assembly="..." namespace="...">
<class name="Customer" table="customers">
- <id name="Id" column="id">
- <generator class="native"/>
- </id>
+ <id name="Id" column="id" generator="native" />
<property name="Name" column="name"/>
<set name="Orders" inverse="true" lazy="true">
<key column="customer_id"/>
@@ -297,9 +294,7 @@ alter table author_work
</class>
<class name="Order" table="orders">
- <id name="Id" column="id">
- <generator class="native"/>
- </id>
+ <id name="Id" column="id" generator="native" />
<property name="Date" column="date"/>
<many-to-one name="Customer" column="customer_id"/>
<list name="LineItems" table="line_items" lazy="true">
Please sign in to comment.
Something went wrong with that request. Please try again.