Skip to content

Commit e34d751

Browse files
fredericDelaportehazzik
authored andcommitted
Back port doc fixes (#982)
- ORM to <em>; - Mention of LINQ as a querying API; - Example of Delete with a query string; - Included <subselect>; - Replaced load() and get() Java mentions for Load() and Get(); - "be Serializable" -> "marked with the Serializable attribute"; - "seperator" -> "separator"; - Mentioned that NH now only supports generic collections. - Updated list of interfaces that can be used in collection declarations; - All collections made generic; - Added reference to default_flush_mode; - Added reference to query.linq_provider_class; - Removed references to proxyfactory.factory_class; - Fixed reference to MsSqlCe40Dialect; - Removed reference to version 2.0 of NHibernate.Mapping.Attributes; - Various minor corrections.
1 parent 698e5ec commit e34d751

15 files changed

+111
-50
lines changed

doc/reference/modules/basic_mapping.xml

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,47 @@
418418
</para>
419419
</sect2>
420420

421+
<sect2 id="mapping-declaration-subselect">
422+
<title>subselect</title>
423+
424+
<para>
425+
An alternative to mapping a class to table or view columns is to map a <emphasis>query</emphasis>.
426+
For that, we use the <literal>&lt;subselect&gt;</literal> element, which is mutually
427+
exclusive with <literal>&lt;subclass&gt;</literal>, <literal>&lt;joined-subclass&gt;</literal>
428+
and <literal>&lt;union-subclass&gt;</literal>.
429+
The content of the <literal>subselect</literal> element is a SQL query:
430+
</para>
431+
432+
<programlisting>&lt;subselect&gt;
433+
&lt;![CDATA[
434+
SELECT cat.ID, cat.NAME, cat.SEX, cat.MATE FROM cat
435+
]]&gt;
436+
&lt;/subselect&gt;]]></programlisting>
437+
438+
<para>
439+
Usually, when mapping a query using <literal>subselect</literal> you will want to mark
440+
the class as not mutable (<literal>mutable="false"</literal>), unless you specify custom
441+
SQL for performing the UPDATE, DELETE and INSERT operations.
442+
</para>
443+
444+
<para>
445+
Also, it makes sense to force synchronization of the tables affected by the query, using
446+
one or more <literal>&lt;synchronize&gt;</literal> entries:
447+
</para>
448+
449+
<programlisting>&lt;subselect&gt;
450+
&lt;![CDATA[
451+
SELECT cat.ID, cat.NAME, cat.SEX, cat.MATE FROM cat
452+
]]&gt;
453+
&lt;/subselect&gt;
454+
&lt;syncronize table="cat"/&gt;]]></programlisting>
455+
456+
<para>
457+
You then still have to declare the class id and properties.
458+
</para>
459+
460+
</sect2>
461+
421462
<sect2 id="mapping-declaration-id">
422463
<title>id</title>
423464

@@ -691,16 +732,16 @@
691732
<programlisting><![CDATA[<id name="Id" type="String" column="cat_id">
692733
<generator class="uuid.hex">
693734
<param name="format">format_value</param>
694-
<param name="seperator">seperator_value</param>
735+
<param name="separator">separator_value</param>
695736
</generator>
696737
</id>]]></programlisting>
697738

698739
<para>
699740
The UUID is generated by calling <literal>Guid.NewGuid().ToString(format)</literal>.
700741
The valid values for <literal>format</literal> are described in the MSDN documentation.
701-
The default <literal>seperator</literal> is <literal>-</literal> and should rarely be
742+
The default <literal>separator</literal> is <literal>-</literal> and should rarely be
702743
modified. The <literal>format</literal> determines if the configured
703-
<literal>seperator</literal> can replace the default separator used by
744+
<literal>separator</literal> can replace the default separator used by
704745
the <literal>format</literal>.
705746
</para>
706747
</sect3>
@@ -1004,14 +1045,14 @@
10041045
<para>
10051046
Your persistent class <emphasis>must</emphasis> override <literal>Equals()</literal>
10061047
and <literal>GetHashCode()</literal> to implement composite identifier equality. It must
1007-
also be <literal>Serializable</literal>.
1048+
also be marked with the <literal>Serializable</literal> attribute.
10081049
</para>
10091050

10101051
<para>
10111052
Unfortunately, this approach to composite identifiers means that a persistent object
10121053
is its own identifier. There is no convenient "handle" other than the object itself.
10131054
You must instantiate an instance of the persistent class itself and populate its
1014-
identifier properties before you can <literal>load()</literal> the persistent state
1055+
identifier properties before you can <literal>Load()</literal> the persistent state
10151056
associated with a composite key. We will describe a much more
10161057
convenient approach where the composite identifier is implemented as a separate class
10171058
in <xref linkend="components-compositeid"/>. The attributes described below apply only

doc/reference/modules/collection_mapping.xml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<para>
88
NHibernate requires that persistent collection-valued fields be declared
9-
as an interface type, for example:
9+
as a generic interface type, for example:
1010
</para>
1111

1212
<programlisting><![CDATA[public class Product
@@ -18,9 +18,6 @@
1818

1919
<para>
2020
The actual interface might be
21-
<literal>System.Collections.ICollection</literal>,
22-
<literal>System.Collections.IList</literal>,
23-
<literal>System.Collections.IDictionary</literal>,
2421
<literal>System.Collections.Generic.ICollection&lt;T&gt;</literal>,
2522
<literal>System.Collections.Generic.IList&lt;T&gt;</literal>,
2623
<literal>System.Collections.Generic.IDictionary&lt;K, V&gt;</literal>,
@@ -31,11 +28,11 @@
3128

3229
<para>
3330
Notice how we initialized the instance variable with an instance of
34-
<literal>HashSet</literal>. This is the best way to initialize collection
31+
<literal>HashSet&lt;T&gt;</literal>. This is the best way to initialize collection
3532
valued properties of newly instantiated (non-persistent) instances. When
3633
you make the instance persistent - by calling <literal>Save()</literal>,
37-
for example - NHibernate will actually replace the <literal>HashSet</literal>
38-
with an instance of NHibernate's own implementation of <literal>ISet</literal>.
34+
for example - NHibernate will actually replace the <literal>HashSet&lt;T&gt;</literal>
35+
with an instance of NHibernate's own implementation of <literal>ISet&lt;T&gt;</literal>.
3936
Watch out for errors like this:
4037
</para>
4138

@@ -242,9 +239,8 @@ HashSet<Cat> hs = (HashSet<Cat>) cat.Kittens; //Error!]]></programlisting>
242239
</callout>
243240
<callout arearefs="mappingcollection14">
244241
<para>
245-
<literal>generic</literal> (optional): Choose between generic and non-generic collection
246-
interface. If this option is not specified, NHibernate will use reflection to choose
247-
the interface.
242+
<literal>generic</literal> (optional, obsolete): Choose between generic and non-generic
243+
collection interfaces. But currently NHibernate only supports generic collections.
248244
</para>
249245
</callout>
250246
</calloutlist>

doc/reference/modules/component_mapping.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@
215215
<itemizedlist spacing="compact">
216216
<listitem>
217217
<para>
218-
It must be <literal>Serializable</literal>.
218+
It must be marked with the <literal>Serializable</literal> attribute.
219219
</para>
220220
</listitem>
221221
<listitem>

doc/reference/modules/configuration.xml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,14 @@ var session = sessions.OpenSession(conn);
206206
<literal>connection.provider</literal>
207207
</entry>
208208
<entry>
209-
The type of a custom <literal>IConnectionProvider</literal>.
209+
The type of a custom <literal>IConnectionProvider</literal> implementation.
210210
<para>
211211
<emphasis role="strong">eg.</emphasis>
212212
<literal>full.classname.of.ConnectionProvider</literal> if the Provider
213213
is built into NHibernate, or <literal>full.classname.of.ConnectionProvider,
214214
assembly</literal> if using an implementation of <literal>IConnectionProvider</literal>
215-
not included in NHibernate.
215+
not included in NHibernate. The default is
216+
<literal>NHibernate.Connection.DriverConnectionProvider</literal>.
216217
</para>
217218
</entry>
218219
</row>
@@ -523,6 +524,15 @@ var session = sessions.OpenSession(conn);
523524
</para>
524525
</entry>
525526
</row>
527+
<row>
528+
<entry>
529+
<literal>query.linq_provider_class</literal>
530+
</entry>
531+
<entry>
532+
The classname of a custom LINQ provider class, one that implements <literal>INhQueryProvider</literal>.
533+
The default is <literal>DefaultQueryProvider</literal>.
534+
</entry>
535+
</row>
526536
<row>
527537
<entry>
528538
<literal>show_sql</literal>
@@ -602,6 +612,14 @@ var session = sessions.OpenSession(conn);
602612
</para>
603613
</entry>
604614
</row>
615+
<row>
616+
<entry>
617+
<literal>default_flush_mode</literal>
618+
</entry>
619+
<entry>
620+
The default <literal>FlushMode</literal>, <literal>Auto</literal> when not specified.
621+
</entry>
622+
</row>
605623
</tbody>
606624
</tgroup>
607625
</table>
@@ -709,11 +727,11 @@ var session = sessions.OpenSession(conn);
709727
</row>
710728
<row>
711729
<entry>Microsoft SQL Server Compact Edition</entry>
712-
<entry><literal>NHibernate.Dialect.MsSqlCe40Dialect</literal></entry>
730+
<entry><literal>NHibernate.Dialect.MsSqlCeDialect</literal></entry>
713731
</row>
714732
<row>
715733
<entry>Microsoft SQL Server Compact Edition 4.0</entry>
716-
<entry><literal>NHibernate.Dialect.MsSqlCeDialect</literal></entry>
734+
<entry><literal>NHibernate.Dialect.MsSqlCe40Dialect</literal></entry>
717735
</row>
718736
<row>
719737
<entry>MySQL 3 or 4</entry>

doc/reference/modules/inheritance_mapping.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@
429429
<entry>Polymorphic one-to-one</entry>
430430
<entry>Polymorphic one-to-many</entry>
431431
<entry>Polymorphic many-to-many</entry>
432-
<entry>Polymorphic <literal>load()/get()</literal></entry>
432+
<entry>Polymorphic <literal>Load()/Get()</literal></entry>
433433
<entry>Polymorphic queries</entry>
434434
<entry>Polymorphic joins</entry>
435435
<entry>Outer join fetching</entry>

doc/reference/modules/manipulating_data.xml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ long generatedId = (long) sess.Save(fritz);]]></programlisting>
2222
pk.Color = Color.Tabby;
2323
pk.Sex = 'F';
2424
pk.Name = "PK";
25-
pk.Kittens = new HashSet();
25+
pk.Kittens = new HashSet<Cat>();
2626
pk.AddKitten(fritz);
2727
sess.Save( pk, 1234L );]]></programlisting>
2828

@@ -62,7 +62,7 @@ DomesticCat pk = sess.Load<DomesticCat>(pkId);]]></programlisting>
6262
<programlisting><![CDATA[Cat cat = new DomesticCat();
6363
// load pk's state into cat
6464
sess.Load( cat, pkId );
65-
ISet kittens = cat.Kittens;]]></programlisting>
65+
var kittens = cat.Kittens;]]></programlisting>
6666

6767
<para>
6868
Note that <literal>Load()</literal> will throw an unrecoverable exception if there is no matching
@@ -460,7 +460,7 @@ sess.Flush(); // changes to cat are automatically detected and persisted]]></pr
460460
usually use versioned data to ensure transaction isolation.) This approach
461461
requires a slightly different programming model to the one described in the
462462
last section. NHibernate supports this model by providing the
463-
method <literal>Session.Update()</literal>.
463+
method <literal>ISession.Update()</literal>.
464464
</para>
465465

466466
<programlisting><![CDATA[// in the first session
@@ -684,6 +684,8 @@ sess.Lock(pk, LockMode.Upgrade);]]></programlisting>
684684
<literal>Delete()</literal>.
685685
</para>
686686

687+
<programlisting><![CDATA[sess.Delete("from Cat");]]></programlisting>
688+
687689
<para>
688690
You may now delete objects in any order you like, without risk of foreign key
689691
constraint violations. Of course, it is still possible to violate a <literal>NOT
@@ -926,9 +928,11 @@ sess.Close();]]></programlisting>
926928
For exceptions thrown by the data provider while interacting with the database,
927929
NHibernate will wrap the error in an instance of <literal>ADOException</literal>.
928930
The underlying exception is accessible by calling <literal>ADOException.InnerException</literal>.
929-
NHibernate converts the DbException into an appropriate ADOException subclass using the ISQLExceptionConverter attached to the SessionFactory.
930-
By default, the ISQLExceptionConverter is defined by the configured dialect; however, it is also possible to plug in a custom implementation
931-
(see the api-docs for the ISQLExceptionConverter class for details).
931+
NHibernate converts the <literal>DbException</literal> into an appropriate <literal>ADOException</literal>
932+
subclass using the <literal>ISQLExceptionConverter</literal> attached to the SessionFactory.
933+
By default, the <literal>ISQLExceptionConverter</literal> is defined by the configured dialect;
934+
however, it is also possible to plug in a custom implementation
935+
(see the api-docs for the <literal>ISQLExceptionConverter</literal> class for details).
932936
</para>
933937

934938
<para>

doc/reference/modules/nhibernate_caches.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
expire when the relevant data in the database changes.
6868
</para>
6969
<para>
70-
SysCache2 requires Microsoft SQL Server 2000 or higher and .NET Framework version 2.0 or higher.
70+
SysCache2 requires Microsoft SQL Server 2000 or higher.
7171
</para>
7272
</listitem>
7373
</varlistentry>
@@ -245,7 +245,7 @@
245245

246246
<para>
247247
A table-based dependency will monitor the data in a database table for changes. Table-based
248-
dependencies are generally used for a SQL Server 2000 database but will work with SQL Server 2005 as
248+
dependencies are generally used for a SQL Server 2000 database but will work with SQL Server 2005 or superior as
249249
well. Before you can use SQL Server cache invalidation with table based dependencies, you need to
250250
enable notifications for the database. This task is performed with the <command>aspnet_regsql</command>
251251
command. With table-based notifications, the application will poll the database for changes at a

doc/reference/modules/nhibernate_mapping_attributes.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ public MyType MyProperty;</programlisting>
248248
<para>Updating <filename>/src/NHibernate.Mapping.Attributes/nhibernate-mapping.xsd</filename> (copy/paste) and running the Generator again (even if it wasn't modified)</para>
249249
</listitem>
250250
<listitem>
251-
<para>Running the Test project and make sure that no exception is thrown. A class/property should be modified/added in this project to be sure that any new breaking change will be caught (=> update the reference hbm.xml files and/or the project <filename>NHibernate.Mapping.Attributes-2.0.csproj</filename>)</para>
251+
<para>Running the Test project and make sure that no exception is thrown. A class/property should be modified/added in this project to be sure that any new breaking change will be caught (=> update the reference hbm.xml files and/or the project <filename>NHibernate.Mapping.Attributes.csproj</filename>)</para>
252252
</listitem>
253253
</orderedlist>
254254
<para>This implementation is based on NHibernate mapping schema; so there is probably lot of "standard schema features" that are not supported...</para>

doc/reference/modules/performance.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ int accessLevel = permissions["accounts"]; // Error!]]></programlisting>
250250
.UniqueResult<User>();]]></programlisting>
251251

252252
<para>
253-
(This is NHibernate's equivalent of what some ORM solutions call a "fetch plan".)
253+
(This is NHibernate's equivalent of what some <emphasis>ORM</emphasis> solutions call a "fetch plan".)
254254
</para>
255255

256256
<para>

doc/reference/modules/persistent_classes.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</para>
2222

2323
<programlisting><![CDATA[using System;
24-
using Iesi.Collections;
24+
using System.Collections.Generic;
2525
2626
namespace Eg
2727
{
@@ -41,7 +41,7 @@ namespace Eg
4141
public virtual DateTime Birthdate { get; set; }
4242
public virtual float Weight { get; set; }
4343
public virtual Color Color { get; set; }
44-
public virtual ISet Kittens { get; set; }
44+
public virtual ISet<Cat> Kittens { get; set; }
4545
public virtual char Sex { get; set; }
4646
4747
// AddKitten not needed by NHibernate
@@ -62,7 +62,7 @@ namespace Eg
6262

6363
<para>
6464
<literal>Cat</literal> declares properties for all the persistent fields.
65-
Many other ORM tools directly persist instance variables. We believe
65+
Many other <emphasis>ORM tools</emphasis> directly persist instance variables. We believe
6666
it is far better to decouple this implementation detail from the persistence
6767
mechanism. NHibernate persists properties, using their getter and setter methods.
6868
</para>

doc/reference/modules/preface.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<para>
55
Working with object-oriented software and a relational database can be cumbersome
66
and time consuming in today's enterprise environments. NHibernate is an object/relational
7-
mapping tool for .NET environments. The term object/relational mapping (ORM) refers to
7+
mapping tool for .NET environments. The term object/relational mapping (<emphasis>ORM</emphasis>) refers to
88
the technique of mapping a data representation from an object model to a relational
99
data model with a SQL-based schema.
1010
</para>

doc/reference/modules/query_sql.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
</listitem>
4343
</itemizedlist>
4444

45-
<para>This will return an IList of Object arrays (object[]) with
45+
<para>This will return an <literal>IList</literal> of <literal>Object</literal>
46+
arrays (<literal>object[]</literal>) with
4647
scalar values for each column in the CATS table. Only these three
4748
columns will be returned, even though the query is using
4849
<literal>*</literal> and could return more than the three listed

0 commit comments

Comments
 (0)