Skip to content

Back port doc fixes #982

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 46 additions & 5 deletions doc/reference/modules/basic_mapping.xml
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,47 @@
</para>
</sect2>

<sect2 id="mapping-declaration-subselect">
<title>subselect</title>

<para>
An alternative to mapping a class to table or view columns is to map a <emphasis>query</emphasis>.
For that, we use the <literal>&lt;subselect&gt;</literal> element, which is mutually
exclusive with <literal>&lt;subclass&gt;</literal>, <literal>&lt;joined-subclass&gt;</literal>
and <literal>&lt;union-subclass&gt;</literal>.
The content of the <literal>subselect</literal> element is a SQL query:
</para>

<programlisting>&lt;subselect&gt;
&lt;![CDATA[
SELECT cat.ID, cat.NAME, cat.SEX, cat.MATE FROM cat
]]&gt;
&lt;/subselect&gt;]]></programlisting>

<para>
Usually, when mapping a query using <literal>subselect</literal> you will want to mark
the class as not mutable (<literal>mutable="false"</literal>), unless you specify custom
SQL for performing the UPDATE, DELETE and INSERT operations.
</para>

<para>
Also, it makes sense to force synchronization of the tables affected by the query, using
one or more <literal>&lt;synchronize&gt;</literal> entries:
</para>

<programlisting>&lt;subselect&gt;
&lt;![CDATA[
SELECT cat.ID, cat.NAME, cat.SEX, cat.MATE FROM cat
]]&gt;
&lt;/subselect&gt;
&lt;syncronize table="cat"/&gt;]]></programlisting>

<para>
You then still have to declare the class id and properties.
</para>

</sect2>

<sect2 id="mapping-declaration-id">
<title>id</title>

Expand Down Expand Up @@ -691,16 +732,16 @@
<programlisting><![CDATA[<id name="Id" type="String" column="cat_id">
<generator class="uuid.hex">
<param name="format">format_value</param>
<param name="seperator">seperator_value</param>
<param name="separator">separator_value</param>
</generator>
</id>]]></programlisting>

<para>
The UUID is generated by calling <literal>Guid.NewGuid().ToString(format)</literal>.
The valid values for <literal>format</literal> are described in the MSDN documentation.
The default <literal>seperator</literal> is <literal>-</literal> and should rarely be
The default <literal>separator</literal> is <literal>-</literal> and should rarely be
modified. The <literal>format</literal> determines if the configured
<literal>seperator</literal> can replace the default separator used by
<literal>separator</literal> can replace the default separator used by
the <literal>format</literal>.
</para>
</sect3>
Expand Down Expand Up @@ -1004,14 +1045,14 @@
<para>
Your persistent class <emphasis>must</emphasis> override <literal>Equals()</literal>
and <literal>GetHashCode()</literal> to implement composite identifier equality. It must
also be <literal>Serializable</literal>.
also be marked with the <literal>Serializable</literal> attribute.
</para>

<para>
Unfortunately, this approach to composite identifiers means that a persistent object
is its own identifier. There is no convenient "handle" other than the object itself.
You must instantiate an instance of the persistent class itself and populate its
identifier properties before you can <literal>load()</literal> the persistent state
identifier properties before you can <literal>Load()</literal> the persistent state
associated with a composite key. We will describe a much more
convenient approach where the composite identifier is implemented as a separate class
in <xref linkend="components-compositeid"/>. The attributes described below apply only
Expand Down
16 changes: 6 additions & 10 deletions doc/reference/modules/collection_mapping.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

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

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

<para>
The actual interface might be
<literal>System.Collections.ICollection</literal>,
<literal>System.Collections.IList</literal>,
<literal>System.Collections.IDictionary</literal>,
<literal>System.Collections.Generic.ICollection&lt;T&gt;</literal>,
<literal>System.Collections.Generic.IList&lt;T&gt;</literal>,
<literal>System.Collections.Generic.IDictionary&lt;K, V&gt;</literal>,
Expand All @@ -31,11 +28,11 @@

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

Expand Down Expand Up @@ -242,9 +239,8 @@ HashSet<Cat> hs = (HashSet<Cat>) cat.Kittens; //Error!]]></programlisting>
</callout>
<callout arearefs="mappingcollection14">
<para>
<literal>generic</literal> (optional): Choose between generic and non-generic collection
interface. If this option is not specified, NHibernate will use reflection to choose
the interface.
<literal>generic</literal> (optional, obsolete): Choose between generic and non-generic
collection interfaces. But currently NHibernate only supports generic collections.
</para>
</callout>
</calloutlist>
Expand Down
2 changes: 1 addition & 1 deletion doc/reference/modules/component_mapping.xml
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@
<itemizedlist spacing="compact">
<listitem>
<para>
It must be <literal>Serializable</literal>.
It must be marked with the <literal>Serializable</literal> attribute.
</para>
</listitem>
<listitem>
Expand Down
26 changes: 22 additions & 4 deletions doc/reference/modules/configuration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,14 @@ var session = sessions.OpenSession(conn);
<literal>connection.provider</literal>
</entry>
<entry>
The type of a custom <literal>IConnectionProvider</literal>.
The type of a custom <literal>IConnectionProvider</literal> implementation.
<para>
<emphasis role="strong">eg.</emphasis>
<literal>full.classname.of.ConnectionProvider</literal> if the Provider
is built into NHibernate, or <literal>full.classname.of.ConnectionProvider,
assembly</literal> if using an implementation of <literal>IConnectionProvider</literal>
not included in NHibernate.
not included in NHibernate. The default is
<literal>NHibernate.Connection.DriverConnectionProvider</literal>.
</para>
</entry>
</row>
Expand Down Expand Up @@ -523,6 +524,15 @@ var session = sessions.OpenSession(conn);
</para>
</entry>
</row>
<row>
<entry>
<literal>query.linq_provider_class</literal>
</entry>
<entry>
The classname of a custom LINQ provider class, one that implements <literal>INhQueryProvider</literal>.
The default is <literal>DefaultQueryProvider</literal>.
</entry>
</row>
<row>
<entry>
<literal>show_sql</literal>
Expand Down Expand Up @@ -602,6 +612,14 @@ var session = sessions.OpenSession(conn);
</para>
</entry>
</row>
<row>
<entry>
<literal>default_flush_mode</literal>
</entry>
<entry>
The default <literal>FlushMode</literal>, <literal>Auto</literal> when not specified.
</entry>
</row>
</tbody>
</tgroup>
</table>
Expand Down Expand Up @@ -709,11 +727,11 @@ var session = sessions.OpenSession(conn);
</row>
<row>
<entry>Microsoft SQL Server Compact Edition</entry>
<entry><literal>NHibernate.Dialect.MsSqlCe40Dialect</literal></entry>
<entry><literal>NHibernate.Dialect.MsSqlCeDialect</literal></entry>
</row>
<row>
<entry>Microsoft SQL Server Compact Edition 4.0</entry>
<entry><literal>NHibernate.Dialect.MsSqlCeDialect</literal></entry>
<entry><literal>NHibernate.Dialect.MsSqlCe40Dialect</literal></entry>
</row>
<row>
<entry>MySQL 3 or 4</entry>
Expand Down
2 changes: 1 addition & 1 deletion doc/reference/modules/inheritance_mapping.xml
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@
<entry>Polymorphic one-to-one</entry>
<entry>Polymorphic one-to-many</entry>
<entry>Polymorphic many-to-many</entry>
<entry>Polymorphic <literal>load()/get()</literal></entry>
<entry>Polymorphic <literal>Load()/Get()</literal></entry>
<entry>Polymorphic queries</entry>
<entry>Polymorphic joins</entry>
<entry>Outer join fetching</entry>
Expand Down
16 changes: 10 additions & 6 deletions doc/reference/modules/manipulating_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ long generatedId = (long) sess.Save(fritz);]]></programlisting>
pk.Color = Color.Tabby;
pk.Sex = 'F';
pk.Name = "PK";
pk.Kittens = new HashSet();
pk.Kittens = new HashSet<Cat>();
pk.AddKitten(fritz);
sess.Save( pk, 1234L );]]></programlisting>

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

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

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

<programlisting><![CDATA[sess.Delete("from Cat");]]></programlisting>

<para>
You may now delete objects in any order you like, without risk of foreign key
constraint violations. Of course, it is still possible to violate a <literal>NOT
Expand Down Expand Up @@ -926,9 +928,11 @@ sess.Close();]]></programlisting>
For exceptions thrown by the data provider while interacting with the database,
NHibernate will wrap the error in an instance of <literal>ADOException</literal>.
The underlying exception is accessible by calling <literal>ADOException.InnerException</literal>.
NHibernate converts the DbException into an appropriate ADOException subclass using the ISQLExceptionConverter attached to the SessionFactory.
By default, the ISQLExceptionConverter is defined by the configured dialect; however, it is also possible to plug in a custom implementation
(see the api-docs for the ISQLExceptionConverter class for details).
NHibernate converts the <literal>DbException</literal> into an appropriate <literal>ADOException</literal>
subclass using the <literal>ISQLExceptionConverter</literal> attached to the SessionFactory.
By default, the <literal>ISQLExceptionConverter</literal> is defined by the configured dialect;
however, it is also possible to plug in a custom implementation
(see the api-docs for the <literal>ISQLExceptionConverter</literal> class for details).
</para>

<para>
Expand Down
4 changes: 2 additions & 2 deletions doc/reference/modules/nhibernate_caches.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
expire when the relevant data in the database changes.
</para>
<para>
SysCache2 requires Microsoft SQL Server 2000 or higher and .NET Framework version 2.0 or higher.
SysCache2 requires Microsoft SQL Server 2000 or higher.
</para>
</listitem>
</varlistentry>
Expand Down Expand Up @@ -245,7 +245,7 @@

<para>
A table-based dependency will monitor the data in a database table for changes. Table-based
dependencies are generally used for a SQL Server 2000 database but will work with SQL Server 2005 as
dependencies are generally used for a SQL Server 2000 database but will work with SQL Server 2005 or superior as
well. Before you can use SQL Server cache invalidation with table based dependencies, you need to
enable notifications for the database. This task is performed with the <command>aspnet_regsql</command>
command. With table-based notifications, the application will poll the database for changes at a
Expand Down
2 changes: 1 addition & 1 deletion doc/reference/modules/nhibernate_mapping_attributes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public MyType MyProperty;</programlisting>
<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>
</listitem>
<listitem>
<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>
<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>
</listitem>
</orderedlist>
<para>This implementation is based on NHibernate mapping schema; so there is probably lot of "standard schema features" that are not supported...</para>
Expand Down
2 changes: 1 addition & 1 deletion doc/reference/modules/performance.xml
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ int accessLevel = permissions["accounts"]; // Error!]]></programlisting>
.UniqueResult<User>();]]></programlisting>

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

<para>
Expand Down
6 changes: 3 additions & 3 deletions doc/reference/modules/persistent_classes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</para>

<programlisting><![CDATA[using System;
using Iesi.Collections;
using System.Collections.Generic;

namespace Eg
{
Expand All @@ -41,7 +41,7 @@ namespace Eg
public virtual DateTime Birthdate { get; set; }
public virtual float Weight { get; set; }
public virtual Color Color { get; set; }
public virtual ISet Kittens { get; set; }
public virtual ISet<Cat> Kittens { get; set; }
public virtual char Sex { get; set; }

// AddKitten not needed by NHibernate
Expand All @@ -62,7 +62,7 @@ namespace Eg

<para>
<literal>Cat</literal> declares properties for all the persistent fields.
Many other ORM tools directly persist instance variables. We believe
Many other <emphasis>ORM tools</emphasis> directly persist instance variables. We believe
it is far better to decouple this implementation detail from the persistence
mechanism. NHibernate persists properties, using their getter and setter methods.
</para>
Expand Down
2 changes: 1 addition & 1 deletion doc/reference/modules/preface.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<para>
Working with object-oriented software and a relational database can be cumbersome
and time consuming in today's enterprise environments. NHibernate is an object/relational
mapping tool for .NET environments. The term object/relational mapping (ORM) refers to
mapping tool for .NET environments. The term object/relational mapping (<emphasis>ORM</emphasis>) refers to
the technique of mapping a data representation from an object model to a relational
data model with a SQL-based schema.
</para>
Expand Down
3 changes: 2 additions & 1 deletion doc/reference/modules/query_sql.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
</listitem>
</itemizedlist>

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