Skip to content

Commit 0891c13

Browse files
authored
Merge pull request #1395 from fredericDelaporte/EvenMoreDocFixes
Documentation fixes
2 parents 97f13e7 + 14c989f commit 0891c13

File tree

4 files changed

+185
-34
lines changed

4 files changed

+185
-34
lines changed

doc/reference/modules/component_mapping.xml

+6
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,12 @@
225225
notion of composite key equality.
226226
</para>
227227
</listitem>
228+
<listitem>
229+
<para>
230+
It should re-implement <literal>ToString()</literal> if you consider
231+
using the second level cache. See <xref linkend="NHibernate.Caches-howto" />.
232+
</para>
233+
</listitem>
228234
</itemizedlist>
229235

230236
<para>

doc/reference/modules/configuration.xml

+41-15
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,6 @@ var session = sessions.OpenSession(conn);
146146
<literal>Configuration.SetProperties()</literal>.
147147
</para>
148148
</listitem>
149-
<listitem>
150-
<para>
151-
Add the properties to a configuration section in the application
152-
configuration file. The section should be named <literal>nhibernate</literal>
153-
and its handler set to <literal>System.Configuration.NameValueSectionHandler</literal>.
154-
</para>
155-
</listitem>
156149
<listitem>
157150
<para>
158151
Include <literal>&lt;property&gt;</literal> elements in a configuration
@@ -449,13 +442,11 @@ var session = sessions.OpenSession(conn);
449442
</para>
450443

451444
<para>
452-
System-level properties can only be set manually by setting static properties of
445+
Some properties are system-level properties. They can only be set manually by setting static properties of
453446
<literal>NHibernate.Cfg.Environment</literal> class or be defined in the
454-
<literal>&lt;nhibernate&gt;</literal> section of the application
455-
configuration file. These properties cannot be set using
456-
<literal>Configuration.SetProperties</literal> or be defined in the
457-
<literal>&lt;hibernate-configuration&gt;</literal> section of the application configuration
458-
file.
447+
<literal>&lt;hibernate-configuration&gt;</literal> section of the application
448+
configuration file. These properties cannot be set using <literal>Configuration.SetProperties</literal> or
449+
the <literal>hibernate.cfg.xml</literal> configuration file.
459450
</para>
460451

461452
<table frame="topbot" id="configuration-optional-properties" revision="3">
@@ -529,7 +520,7 @@ var session = sessions.OpenSession(conn);
529520
</entry>
530521
<entry>
531522
Enables use of a runtime-generated class to set or get properties of an entity
532-
or component instead of using runtime reflection (System-level property).
523+
or component instead of using runtime reflection. This is a system-level property.
533524
The use of the reflection optimizer inflicts a certain startup cost on the
534525
application but should lead to better performance in the long run.
535526
Defaults to <literal>true</literal>.
@@ -552,9 +543,17 @@ var session = sessions.OpenSession(conn);
552543
</entry>
553544
<entry>
554545
Specifies the bytecode provider to use to optimize the use of reflection in NHibernate.
546+
This is a system-level property.
555547
Use <literal>null</literal> to disable the optimization completely, <literal>lcg</literal>
556548
to use built-in lightweight code generation, or the class name of a custom
557549
<literal>IBytecodeProvider</literal> implementation. Defaults to <literal>lcg</literal>.
550+
<para>
551+
You can not set this property in <literal>hibernate.cfg.xml</literal>, but only
552+
in <literal>&lt;hibernate-configuration&gt;</literal> section of the application
553+
configuration file or by code by setting
554+
<literal>NHibernate.Cfg.Environment.BytecodeProvider</literal>
555+
before creating any <literal>NHibernate.Cfg.Configuration</literal> instance.
556+
</para>
558557
<para>
559558
<emphasis role="strong">eg.</emphasis>
560559
<literal>null</literal> | <literal>lcg</literal> |
@@ -1092,6 +1091,33 @@ in the parameter binding.</programlisting>
10921091
</para>
10931092
</entry>
10941093
</row>
1094+
<row>
1095+
<entry>
1096+
<literal>nhibernate-logger</literal>
1097+
</entry>
1098+
<entry>
1099+
The class name of an <literal>ILoggerFactory</literal> implementation. It allows using another
1100+
logger than log4net.
1101+
<para>
1102+
The default is not defined, which causes NHibernate to search for log4net assembly. If this
1103+
search succeeds, NHibernate will log with log4net. Otherwise, its internal logging will
1104+
be disabled.
1105+
</para>
1106+
<para>
1107+
This is a very special system-level property. It can only be set through an
1108+
<ulink url="https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/appsettings/">appSetting</ulink>
1109+
named <literal>nhibernate-logger</literal> in the application configuration file. It cannot
1110+
be set neither with <literal>NHibernate.Cfg.Environment</literal> class, nor be defined in the
1111+
<literal>&lt;hibernate-configuration&gt;</literal> section of the application
1112+
configuration file, nor supplied by using <literal>Configuration.SetProperties</literal>, nor
1113+
set in the <literal>hibernate.cfg.xml</literal> configuration file.
1114+
</para>
1115+
<para>
1116+
<emphasis role="strong">eg.</emphasis>
1117+
<literal>classname.of.LoggerFactory, assembly</literal>
1118+
</para>
1119+
</entry>
1120+
</row>
10951121
</tbody>
10961122
</tgroup>
10971123
</table>
@@ -1483,7 +1509,7 @@ in the parameter binding.</programlisting>
14831509
<para>
14841510
An alternative approach is to specify a full configuration in a file named
14851511
<literal>hibernate.cfg.xml</literal>. This file can be used as a replacement
1486-
for the <literal>&lt;nhibernate;&gt;</literal> or <literal>&lt;hibernate-configuration&gt;</literal>
1512+
for the <literal>&lt;hibernate-configuration&gt;</literal>
14871513
sections of the application configuration file.
14881514
</para>
14891515

doc/reference/modules/nhibernate_caches.xml

+132-16
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
<programlisting>
126126
&lt;property name="cache.provider_class"&gt;<literal>XXX</literal>&lt;/property&gt;<co id="hibernate.cache.provider_class-co" linkends="hibernate.cache.provider_class"/>
127127
&lt;property name="cache.default_expiration"&gt;<literal>120</literal>&lt;/property&gt;<co id="nhcaches-expiration-co" linkends="nhcaches-expiration"/>
128+
&lt;property name="cache.use_sliding_expiration"&gt;<literal>true</literal>&lt;/property&gt;<co id="nhcaches-sliding-co" linkends="nhcaches-sliding"/>
128129
</programlisting>
129130
<calloutlist>
130131
<callout arearefs="hibernate.cache.provider_class-co" id="hibernate.cache.provider_class">
@@ -138,7 +139,15 @@
138139
<callout arearefs="nhcaches-expiration-co" id="nhcaches-expiration">
139140
<para>
140141
The <literal>expiration</literal> value is the number of seconds you wish
141-
to cache each entry (here two minutes). This example applies to SysCache only.
142+
to cache each entry (here two minutes). Not all providers support this setting, it may
143+
be ignored. Check their respective documentation.
144+
</para>
145+
</callout>
146+
<callout arearefs="nhcaches-sliding-co" id="nhcaches-sliding">
147+
<para>
148+
The <literal>use_sliding_expiration</literal> value is whether you wish to use a
149+
sliding expiration or not. Defaults to <literal>false</literal>.
150+
Not all providers support this setting, it may be ignored. Check their respective documentation.
142151
</para>
143152
</callout>
144153
</calloutlist>
@@ -156,15 +165,31 @@
156165
<formalpara>
157166
<title>Be careful</title>
158167
<para>
159-
Caches are never aware of changes made to the persistent store by another process (though they may be
160-
configured to regularly expire cached data). As the caches are created at the session factory level,
161-
they are destroyed with the SessionFactory instance; so you must keep them alive as long as you need
162-
them.
163-
</para>
164-
<para>
165-
The second level cache requires the use of transactions, be it through transaction scopes or NHibernate
166-
transactions. Interacting with the data store without an explicit transaction is discouraged, and will
167-
not allow the second level cache to work as intended.
168+
<itemizedlist>
169+
<listitem>
170+
<para>
171+
Most caches are never aware of changes made to the persistent store by another process (though they may be
172+
configured to regularly expire cached data). As the caches are created at the session factory level,
173+
they are destroyed with the SessionFactory instance; so you must keep them alive as long as you need
174+
them.
175+
</para>
176+
</listitem>
177+
<listitem>
178+
<para>
179+
The second level cache requires the use of transactions, be it through transaction scopes or NHibernate
180+
transactions. Interacting with the data store without an explicit transaction is discouraged, and will
181+
not allow the second level cache to work as intended.
182+
</para>
183+
</listitem>
184+
<listitem>
185+
<para>
186+
To avoid issues with composite ids and some cache providers, <literal>ToString()</literal> needs to
187+
be overridden on composite id classes. It should yield an unique string representing the id. If the
188+
composite id is mapped as a component, overriding the component <literal>ToString()</literal>
189+
is enough. See <xref linkend="components-compositeid" />.
190+
</para>
191+
</listitem>
192+
</itemizedlist>
168193
</para>
169194
</formalpara>
170195
<para>
@@ -184,29 +209,39 @@
184209
<section id="NHibernate.Caches.SysCache">
185210
<title>SysCache Configuration</title>
186211
<para>
187-
As SysCache relies on <classname>System.Web.Caching.Cache</classname> for the underlying implementation,
188-
the configuration is based on the available options that make sense for NHibernate to utilize.
212+
As SysCache relies on <classname>System.Web.Caching.Cache</classname> for the underlying implementation.
213+
Following NHibernate configuration settings are available:
189214
</para>
190215

191216
<variablelist>
192217
<varlistentry>
193218
<term><literal>expiration</literal></term>
194219
<listitem>
195220
Number of seconds to wait before expiring each item.
221+
Takes precedence over <literal>cache.default_expiration</literal>.
222+
If none of them are defined, defaults to <literal>300</literal>.
223+
</listitem>
224+
</varlistentry>
225+
<varlistentry>
226+
<term><literal>cache.use_sliding_expiration</literal></term>
227+
<listitem>
228+
Should the expiration be sliding? A sliding expiration is reinitialized at each get.
229+
Defaults to <literal>false</literal>.
196230
</listitem>
197231
</varlistentry>
198232
<varlistentry>
199233
<term><literal>priority</literal></term>
200234
<listitem>
201235
A numeric cost of expiring each item, where 1 is a low cost, 5 is the highest, and 3 is normal.
202-
Only values 1 through 5 are valid.
236+
Only values 1 through 5 are valid. 6 is a special value corresponding to
237+
<literal>NotRemovable</literal>, it should not be used.
203238
</listitem>
204239
</varlistentry>
205240
</variablelist>
206241

207242
<para>
208243
SysCache has a config file section handler to allow configuring different expirations and priorities for
209-
different regions. Here's an example:
244+
different regions. Here is an example:
210245
</para>
211246

212247
<example>
@@ -219,7 +254,7 @@
219254
220255
<syscache>
221256
<cache region="foo" expiration="500" priority="4" />
222-
<cache region="bar" expiration="300" priority="3" />
257+
<cache region="bar" expiration="300" priority="3" sliding="true" />
223258
</syscache>
224259
</configuration>]]></programlisting>
225260
</example>
@@ -235,6 +270,28 @@
235270
MSDN documentation.
236271
</para>
237272

273+
<para>
274+
Following NHibernate configuration settings are available:
275+
</para>
276+
277+
<variablelist>
278+
<varlistentry>
279+
<term><literal>expiration</literal></term>
280+
<listitem>
281+
Number of seconds to wait before expiring each item.
282+
Takes precedence over <literal>cache.default_expiration</literal>.
283+
If none of them are defined, defaults to <literal>300</literal>.
284+
</listitem>
285+
</varlistentry>
286+
<varlistentry>
287+
<term><literal>cache.use_sliding_expiration</literal></term>
288+
<listitem>
289+
Should the expiration be sliding? A sliding expiration is reinitialized at each get.
290+
Defaults to <literal>false</literal>.
291+
</listitem>
292+
</varlistentry>
293+
</variablelist>
294+
238295
<para>
239296
To configure cache regions with SqlCacheDependencies a <literal>syscache2</literal> config section must be
240297
defined in the application's configuration file. See the sample below.
@@ -456,7 +513,7 @@
456513
<example>
457514
<title>Relative Expiration</title>
458515

459-
<programlisting><![CDATA[<cacheRegion name="Product" relativeExpiration="300" priority="High" />]]></programlisting>
516+
<programlisting><![CDATA[<cacheRegion name="Product" relativeExpiration="300" priority="High" useSlidingExpiration="true" />]]></programlisting>
460517
</example>
461518

462519
<example>
@@ -472,6 +529,18 @@
472529
<listitem>
473530
<para>
474531
Number of seconds that an individual item will exist in the cache before being removed.
532+
Defaults to <literal>300</literal> if neither <literal>relativeExpiration</literal> nor
533+
<literal>timeOfDayExpiration</literal> are defined, and if no expiration settings are
534+
defined in NHibernate configuration.
535+
</para>
536+
</listitem>
537+
</varlistentry>
538+
<varlistentry>
539+
<term><literal>useSlidingExpiration</literal></term>
540+
<listitem>
541+
<para>
542+
Should the expiration be sliding? A sliding expiration is reinitialized at each get.
543+
Defaults to <literal>false</literal> if not defined in NHibernate configuration.
475544
</para>
476545
</listitem>
477546
</varlistentry>
@@ -498,4 +567,51 @@
498567

499568
</section>
500569

570+
<section id="NHibernate.Caches.RtMemoryCache">
571+
<title>Runtime Memory Configuration</title>
572+
<para>
573+
As runtime memory relies on <classname>System.Runtime.Caching.MemoryCache</classname> for the
574+
underlying implementation.
575+
Following NHibernate configuration settings are available:
576+
</para>
577+
578+
<variablelist>
579+
<varlistentry>
580+
<term><literal>expiration</literal></term>
581+
<listitem>
582+
Number of seconds to wait before expiring each item.
583+
Takes precedence over <literal>cache.default_expiration</literal>.
584+
If none of them are defined, defaults to <literal>300</literal>.
585+
</listitem>
586+
</varlistentry>
587+
<varlistentry>
588+
<term><literal>cache.use_sliding_expiration</literal></term>
589+
<listitem>
590+
Should the expiration be sliding? A sliding expiration is reinitialized at each get.
591+
Defaults to <literal>false</literal>.
592+
</listitem>
593+
</varlistentry>
594+
</variablelist>
595+
596+
<para>
597+
RtMemoryCache has a config file section handler to allow configuring different expirations for
598+
different regions. Here is an example:
599+
</para>
600+
601+
<example>
602+
<programlisting><![CDATA[<?xml version="1.0" encoding="utf-8" ?>
603+
<configuration>
604+
<configSections>
605+
<section name="syscache"
606+
type="NHibernate.Caches.SysCache.SysCacheSectionHandler,NHibernate.Caches.SysCache" />
607+
</configSections>
608+
609+
<syscache>
610+
<cache region="foo" expiration="500" />
611+
<cache region="bar" expiration="300" sliding="true" />
612+
</syscache>
613+
</configuration>]]></programlisting>
614+
</example>
615+
</section>
616+
501617
</chapter>

doc/reference/styles/html.css

+6-3
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ HR {
9292
font-weight:bold;
9393
}
9494

95-
96-
97-
95+
.book > DIV, .chapter, .preface {
96+
max-width: 50em;
97+
margin-left: auto;
98+
margin-right: auto;
99+
font-size: large;
100+
}

0 commit comments

Comments
 (0)