Skip to content

Commit 92de0b7

Browse files
hazzikfredericDelaporte
authored andcommitted
Allow any cache.* property in NHibernate configuration (#1656)
Fixes #1650
1 parent 469d79f commit 92de0b7

File tree

2 files changed

+154
-143
lines changed

2 files changed

+154
-143
lines changed

src/NHibernate.Test/CfgTest/ConfigurationSchemaFixture.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,18 @@ public void Properties()
9595
<session-factory>
9696
<property name='connection.provider'>Value of connection.provider</property>
9797
<property name='default_schema'>Value of default_schema</property>
98+
<property name='cache.some_category.setting_name'>Some cache configuration</property>
9899
</session-factory>
99100
</hibernate-configuration>";
100101

101102
XmlTextReader xtr = new XmlTextReader(xml, XmlNodeType.Document, null);
102103
HibernateConfiguration hc = new HibernateConfiguration(xtr);
103-
Assert.AreEqual(2, hc.SessionFactory.Properties.Count);
104+
Assert.AreEqual(3, hc.SessionFactory.Properties.Count);
104105
Assert.IsTrue(hc.SessionFactory.Properties.ContainsKey("connection.provider"));
105106
Assert.IsTrue(hc.SessionFactory.Properties.ContainsKey("default_schema"));
106107
Assert.AreEqual("Value of connection.provider", hc.SessionFactory.Properties["connection.provider"]);
107108
Assert.AreEqual("Value of default_schema", hc.SessionFactory.Properties["default_schema"]);
109+
Assert.AreEqual("Some cache configuration", hc.SessionFactory.Properties["cache.some_category.setting_name"]);
108110
}
109111

110112
[Test]

src/NHibernate/nhibernate-configuration.xsd

Lines changed: 151 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -70,149 +70,158 @@
7070
<xs:extension base="xs:string">
7171
<xs:attribute name="name" use="required">
7272
<xs:simpleType>
73-
<xs:restriction base="xs:string">
74-
<xs:enumeration value="connection.provider" />
75-
<xs:enumeration value="connection.driver_class" />
76-
<xs:enumeration value="connection.connection_string" />
77-
<xs:enumeration value="connection.isolation" />
78-
<xs:enumeration value="connection.release_mode" />
79-
<xs:enumeration value="connection.connection_string_name" />
80-
<xs:enumeration value="dialect" />
81-
<xs:enumeration value="default_schema" />
82-
<xs:enumeration value="show_sql" />
83-
<xs:enumeration value="max_fetch_depth" />
84-
<xs:enumeration value="current_session_context_class" />
85-
<xs:enumeration value="transaction.factory_class" />
86-
<xs:enumeration value="cache.provider_class" />
87-
<xs:enumeration value="cache.use_query_cache" />
88-
<xs:enumeration value="cache.query_cache_factory" />
89-
<xs:enumeration value="cache.use_second_level_cache" />
90-
<xs:enumeration value="cache.region_prefix" />
91-
<xs:enumeration value="cache.use_minimal_puts" />
92-
<xs:enumeration value="cache.default_expiration" />
93-
<xs:enumeration value="query.substitutions" />
94-
<xs:enumeration value="query.factory_class" />
95-
<xs:enumeration value="query.linq_provider_class" />
96-
<xs:enumeration value="query.imports" />
97-
<xs:enumeration value="hbm2ddl.auto" />
98-
<xs:enumeration value="hbm2ddl.keywords" />
99-
<xs:enumeration value="sql_exception_converter" />
100-
<xs:enumeration value="adonet.wrap_result_sets" />
101-
<xs:enumeration value="prepare_sql" />
102-
<xs:enumeration value="command_timeout">
103-
<xs:annotation>
104-
<xs:documentation>
105-
Set the default timeout in seconds for ADO.NET queries.
106-
</xs:documentation>
107-
</xs:annotation>
108-
</xs:enumeration>
109-
<xs:enumeration value="adonet.batch_size" />
110-
<xs:enumeration value="use_proxy_validator" />
111-
<xs:enumeration value="xml.output_stylesheet" />
112-
<xs:enumeration value="generate_statistics" />
113-
<xs:enumeration value="query.startup_check" />
114-
<xs:enumeration value="default_catalog" />
115-
<xs:enumeration value="proxyfactory.factory_class" />
116-
<xs:enumeration value="adonet.factory_class" />
117-
<xs:enumeration value="default_batch_fetch_size" />
118-
<xs:enumeration value="default_entity_mode" />
119-
<xs:enumeration value="default_flush_mode" />
120-
<xs:enumeration value="use_sql_comments" />
121-
<xs:enumeration value="format_sql" />
122-
<xs:enumeration value="collectiontype.factory_class" />
123-
<xs:enumeration value="order_inserts" />
124-
<xs:enumeration value="order_updates" />
125-
<xs:enumeration value="query.query_model_rewriter_factory" />
126-
<xs:enumeration value="linqtohql.generatorsregistry" />
127-
<xs:enumeration value="odbc.explicit_datetime_scale" />
128-
<xs:enumeration value="adonet.batch_versioned_data" />
129-
<xs:enumeration value="transaction.system_completion_lock_timeout">
130-
<xs:annotation>
131-
<xs:documentation>
132-
Timeout duration in milliseconds for the system transaction completion lock.
73+
<xs:union>
74+
<xs:simpleType>
75+
<xs:restriction base="xs:string">
76+
<xs:enumeration value="connection.provider" />
77+
<xs:enumeration value="connection.driver_class" />
78+
<xs:enumeration value="connection.connection_string" />
79+
<xs:enumeration value="connection.isolation" />
80+
<xs:enumeration value="connection.release_mode" />
81+
<xs:enumeration value="connection.connection_string_name" />
82+
<xs:enumeration value="dialect" />
83+
<xs:enumeration value="default_schema" />
84+
<xs:enumeration value="show_sql" />
85+
<xs:enumeration value="max_fetch_depth" />
86+
<xs:enumeration value="current_session_context_class" />
87+
<xs:enumeration value="transaction.factory_class" />
88+
<xs:enumeration value="cache.provider_class" />
89+
<xs:enumeration value="cache.use_query_cache" />
90+
<xs:enumeration value="cache.query_cache_factory" />
91+
<xs:enumeration value="cache.use_second_level_cache" />
92+
<xs:enumeration value="cache.region_prefix" />
93+
<xs:enumeration value="cache.use_minimal_puts" />
94+
<xs:enumeration value="cache.default_expiration" />
95+
<xs:enumeration value="query.substitutions" />
96+
<xs:enumeration value="query.factory_class" />
97+
<xs:enumeration value="query.linq_provider_class" />
98+
<xs:enumeration value="query.imports" />
99+
<xs:enumeration value="hbm2ddl.auto" />
100+
<xs:enumeration value="hbm2ddl.keywords" />
101+
<xs:enumeration value="sql_exception_converter" />
102+
<xs:enumeration value="adonet.wrap_result_sets" />
103+
<xs:enumeration value="prepare_sql" />
104+
<xs:enumeration value="command_timeout">
105+
<xs:annotation>
106+
<xs:documentation>
107+
Set the default timeout in seconds for ADO.NET queries.
108+
</xs:documentation>
109+
</xs:annotation>
110+
</xs:enumeration>
111+
<xs:enumeration value="adonet.batch_size" />
112+
<xs:enumeration value="use_proxy_validator" />
113+
<xs:enumeration value="xml.output_stylesheet" />
114+
<xs:enumeration value="generate_statistics" />
115+
<xs:enumeration value="query.startup_check" />
116+
<xs:enumeration value="default_catalog" />
117+
<xs:enumeration value="proxyfactory.factory_class" />
118+
<xs:enumeration value="adonet.factory_class" />
119+
<xs:enumeration value="default_batch_fetch_size" />
120+
<xs:enumeration value="default_entity_mode" />
121+
<xs:enumeration value="default_flush_mode" />
122+
<xs:enumeration value="use_sql_comments" />
123+
<xs:enumeration value="format_sql" />
124+
<xs:enumeration value="collectiontype.factory_class" />
125+
<xs:enumeration value="order_inserts" />
126+
<xs:enumeration value="order_updates" />
127+
<xs:enumeration value="query.query_model_rewriter_factory" />
128+
<xs:enumeration value="linqtohql.generatorsregistry" />
129+
<xs:enumeration value="odbc.explicit_datetime_scale" />
130+
<xs:enumeration value="adonet.batch_versioned_data" />
131+
<xs:enumeration value="transaction.system_completion_lock_timeout">
132+
<xs:annotation>
133+
<xs:documentation>
134+
Timeout duration in milliseconds for the system transaction completion lock.
133135

134-
When a system transaction completes, it may have its completion events running on concurrent threads,
135-
after scope disposal. This occurs when the transaction is distributed.
136-
This notably concerns ISessionImplementor.AfterTransactionCompletion(bool, ITransaction).
137-
NHibernate protects the session from being concurrently used by the code following the scope disposal
138-
with a lock. To prevent any application freeze, this lock has a default timeout of five seconds. If the
139-
application appears to require longer (!) running transaction completion events, this setting allows to
140-
raise this timeout. -1 disables the timeout.
141-
</xs:documentation>
142-
</xs:annotation>
143-
</xs:enumeration>
144-
<xs:enumeration value="transaction.use_connection_on_system_prepare">
145-
<xs:annotation>
146-
<xs:documentation>
147-
When a system transaction is being prepared/prepared, is using connection during this process enabled?
148-
Default is true, for supporting FlushMode.Commit with transaction factories
149-
supporting system transactions. But this requires enlisting additional connections, retaining disposed
150-
sessions and their connections till transaction end, and may trigger undesired transaction promotions to
151-
distributed. Set to false for disabling using connections from system
152-
transaction preparation, while still benefiting from FlushMode.Auto on querying.
153-
</xs:documentation>
154-
</xs:annotation>
155-
</xs:enumeration>
156-
<xs:enumeration value="oracle.use_n_prefixed_types_for_unicode">
157-
<xs:annotation>
158-
<xs:documentation>
159-
Oracle has a dual Unicode support model.
160-
Either the whole database use an Unicode encoding, and then all string types
161-
will be Unicode. In such case, Unicode strings should be mapped to non N prefixed
162-
types, such as Varchar2. This is the default.
163-
Or N prefixed types such as NVarchar2 are to be used for Unicode strings.
164-
See https://docs.oracle.com/cd/B19306_01/server.102/b14225/ch6unicode.htm#CACHCAHF
165-
https://docs.oracle.com/database/121/ODPNT/featOraCommand.htm#i1007557
166-
This setting applies only to Oracle dialects and ODP.Net managed or unmanaged driver.
167-
</xs:documentation>
168-
</xs:annotation>
169-
</xs:enumeration>
170-
<xs:enumeration value="sql_types.keep_datetime">
171-
<xs:annotation>
172-
<xs:documentation>
173-
Disable switching built-in NHibernate date-time types from DbType.DateTime to DbType.DateTime2
174-
for dialects supporting datetime2.
175-
</xs:documentation>
176-
</xs:annotation>
177-
</xs:enumeration>
178-
<xs:enumeration value="query.default_cast_length">
179-
<xs:annotation>
180-
<xs:documentation>
181-
Set the default length used in casting when the target type is length bound and
182-
does not specify it. 4000 by default, automatically trimmed down according to dialect type registration.
183-
</xs:documentation>
184-
</xs:annotation>
185-
</xs:enumeration>
186-
<xs:enumeration value="query.default_cast_precision">
187-
<xs:annotation>
188-
<xs:documentation>
189-
Set the default precision used in casting when the target type is decimal and
190-
does not specify it. 29 by default, automatically trimmed down according to dialect type registration.
191-
</xs:documentation>
192-
</xs:annotation>
193-
</xs:enumeration>
194-
<xs:enumeration value="query.default_cast_scale">
195-
<xs:annotation>
196-
<xs:documentation>
197-
Set the default scale used in casting when the target type is decimal and
198-
does not specify it. 10 by default, automatically trimmed down according to dialect type registration.
199-
</xs:documentation>
200-
</xs:annotation>
201-
</xs:enumeration>
202-
<xs:enumeration value="track_session_id">
203-
<xs:annotation>
204-
<xs:documentation>
205-
Set whether tracking the session id or not. When true, each session will have an unique Guid
206-
that can be retrieved by ISessionImplementor.SessionId, otherwise ISessionImplementor.SessionId will
207-
always be Guid.Empty. Session id is used for logging purpose that can be also retrieved in a static
208-
context by SessionIdLoggingContext.SessionId, where the current session id is stored, when tracking
209-
is enabled. In case the current session id won't be used, it is recommended to disable it, in order
210-
to increase performance.
211-
True by default.
212-
</xs:documentation>
213-
</xs:annotation>
214-
</xs:enumeration>
215-
</xs:restriction>
136+
When a system transaction completes, it may have its completion events running on concurrent threads,
137+
after scope disposal. This occurs when the transaction is distributed.
138+
This notably concerns ISessionImplementor.AfterTransactionCompletion(bool, ITransaction).
139+
NHibernate protects the session from being concurrently used by the code following the scope disposal
140+
with a lock. To prevent any application freeze, this lock has a default timeout of five seconds. If the
141+
application appears to require longer (!) running transaction completion events, this setting allows to
142+
raise this timeout. -1 disables the timeout.
143+
</xs:documentation>
144+
</xs:annotation>
145+
</xs:enumeration>
146+
<xs:enumeration value="transaction.use_connection_on_system_prepare">
147+
<xs:annotation>
148+
<xs:documentation>
149+
When a system transaction is being prepared/prepared, is using connection during this process enabled?
150+
Default is true, for supporting FlushMode.Commit with transaction factories
151+
supporting system transactions. But this requires enlisting additional connections, retaining disposed
152+
sessions and their connections till transaction end, and may trigger undesired transaction promotions to
153+
distributed. Set to false for disabling using connections from system
154+
transaction preparation, while still benefiting from FlushMode.Auto on querying.
155+
</xs:documentation>
156+
</xs:annotation>
157+
</xs:enumeration>
158+
<xs:enumeration value="oracle.use_n_prefixed_types_for_unicode">
159+
<xs:annotation>
160+
<xs:documentation>
161+
Oracle has a dual Unicode support model.
162+
Either the whole database use an Unicode encoding, and then all string types
163+
will be Unicode. In such case, Unicode strings should be mapped to non N prefixed
164+
types, such as Varchar2. This is the default.
165+
Or N prefixed types such as NVarchar2 are to be used for Unicode strings.
166+
See https://docs.oracle.com/cd/B19306_01/server.102/b14225/ch6unicode.htm#CACHCAHF
167+
https://docs.oracle.com/database/121/ODPNT/featOraCommand.htm#i1007557
168+
This setting applies only to Oracle dialects and ODP.Net managed or unmanaged driver.
169+
</xs:documentation>
170+
</xs:annotation>
171+
</xs:enumeration>
172+
<xs:enumeration value="sql_types.keep_datetime">
173+
<xs:annotation>
174+
<xs:documentation>
175+
Disable switching built-in NHibernate date-time types from DbType.DateTime to DbType.DateTime2
176+
for dialects supporting datetime2.
177+
</xs:documentation>
178+
</xs:annotation>
179+
</xs:enumeration>
180+
<xs:enumeration value="query.default_cast_length">
181+
<xs:annotation>
182+
<xs:documentation>
183+
Set the default length used in casting when the target type is length bound and
184+
does not specify it. 4000 by default, automatically trimmed down according to dialect type registration.
185+
</xs:documentation>
186+
</xs:annotation>
187+
</xs:enumeration>
188+
<xs:enumeration value="query.default_cast_precision">
189+
<xs:annotation>
190+
<xs:documentation>
191+
Set the default precision used in casting when the target type is decimal and
192+
does not specify it. 29 by default, automatically trimmed down according to dialect type registration.
193+
</xs:documentation>
194+
</xs:annotation>
195+
</xs:enumeration>
196+
<xs:enumeration value="query.default_cast_scale">
197+
<xs:annotation>
198+
<xs:documentation>
199+
Set the default scale used in casting when the target type is decimal and
200+
does not specify it. 10 by default, automatically trimmed down according to dialect type registration.
201+
</xs:documentation>
202+
</xs:annotation>
203+
</xs:enumeration>
204+
<xs:enumeration value="track_session_id">
205+
<xs:annotation>
206+
<xs:documentation>
207+
Set whether tracking the session id or not. When true, each session will have an unique Guid
208+
that can be retrieved by ISessionImplementor.SessionId, otherwise ISessionImplementor.SessionId will
209+
always be Guid.Empty. Session id is used for logging purpose that can be also retrieved in a static
210+
context by SessionIdLoggingContext.SessionId, where the current session id is stored, when tracking
211+
is enabled. In case the current session id won't be used, it is recommended to disable it, in order
212+
to increase performance.
213+
True by default.
214+
</xs:documentation>
215+
</xs:annotation>
216+
</xs:enumeration>
217+
</xs:restriction>
218+
</xs:simpleType>
219+
<xs:simpleType>
220+
<xs:restriction base="xs:string">
221+
<xs:pattern value="cache\.[\w._]+"/>
222+
</xs:restriction>
223+
</xs:simpleType>
224+
</xs:union>
216225
</xs:simpleType>
217226
</xs:attribute>
218227
</xs:extension>

0 commit comments

Comments
 (0)