Skip to content

Commit 3ba71ee

Browse files
Support Unicode in Oracle tests
1 parent bf0e2d8 commit 3ba71ee

File tree

6 files changed

+52
-3
lines changed

6 files changed

+52
-3
lines changed

build-common/common-project.xml

+21-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
<namespace prefix="hbm" uri="urn:nhibernate-configuration-2.2" />
142142
</namespaces>
143143
</xmlpoke>
144-
144+
145145
<!-- Make sure the property exists - it's only set for some scenarios. -->
146146
<property name="nhibernate.odbc.explicit_datetime_scale" value="" unless="${property::exists('nhibernate.odbc.explicit_datetime_scale')}"/>
147147
<xmlpoke file="${app.config}"
@@ -151,6 +151,26 @@
151151
<namespace prefix="hbm" uri="urn:nhibernate-configuration-2.2" />
152152
</namespaces>
153153
</xmlpoke>
154+
155+
<!-- Make sure the property exists - it's only set for some scenarios. -->
156+
<property name="nhibernate.oracle.use_n_prefixed_types_for_unicode" value="" unless="${property::exists('nhibernate.oracle.use_n_prefixed_types_for_unicode')}"/>
157+
<xmlpoke file="${app.config}"
158+
xpath="//*/hbm:property[@name='oracle.use_n_prefixed_types_for_unicode']"
159+
value="${nhibernate.oracle.use_n_prefixed_types_for_unicode}">
160+
<namespaces>
161+
<namespace prefix="hbm" uri="urn:nhibernate-configuration-2.2" />
162+
</namespaces>
163+
</xmlpoke>
164+
165+
<!-- Make sure the property exists - it's only set for some scenarios. -->
166+
<property name="nhibernate.query.default_cast_length" value="" unless="${property::exists('nhibernate.query.default_cast_length')}"/>
167+
<xmlpoke file="${app.config}"
168+
xpath="//*/hbm:property[@name='query.default_cast_length']"
169+
value="${nhibernate.query.default_cast_length}">
170+
<namespaces>
171+
<namespace prefix="hbm" uri="urn:nhibernate-configuration-2.2" />
172+
</namespaces>
173+
</xmlpoke>
154174
</target>
155175

156176
<target name="common.remove-connection-settings-from-app-config">

build-common/teamcity-hibernate.cfg.xml

+2
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,7 @@
2424
<property name="adonet.wrap_result_sets">false</property>
2525

2626
<property name="odbc.explicit_datetime_scale"></property>
27+
<property name="oracle.use_n_prefixed_types_for_unicode"></property>
28+
<property name="query.default_cast_length"></property>
2729
</session-factory>
2830
</hibernate-configuration>

lib/teamcity/oracle/oracle_installation.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ Installation steps for Oracle for NH TeamCity:
77

88
2. Run the installer ...
99
3. Choose any HTTP port for the listener if asked (it may automatically choose the default 8080 if available);
10-
4. Choose the ASCII character set. You will have to ensure nhibernate.oracle.use_n_prefixed_types_for_unicode
11-
parameter is set to true; Choosing instead the Unicode character set will cause some NHibernate tests to fail.
10+
4. Choose the ASCII character set. You will have to ensure oracle.use_n_prefixed_types_for_unicode
11+
parameter is set to true and that query.default_cast_length is set to 2000. Choosing instead the Unicode
12+
character set will cause some NHibernate tests to fail.
1213
5. Enter 'password' as the password for the SYS and SYSTEM accounts;
1314
6. The setup should install Oracle on the machine.
1415

src/NHibernate.Config.Templates/Oracle-Managed.cfg.xml

+7
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,12 @@ for your own use before compile tests in VisualStudio.
1414
<property name="show_sql">false</property>
1515
<property name="dialect">NHibernate.Dialect.Oracle10gDialect</property>
1616
<property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
17+
<!-- If your database setup use an ASCII charset, switch following property to true. -->
18+
<property name="oracle.use_n_prefixed_types_for_unicode">false</property>
19+
<!-- Depending on your database setup, the default cast length of 4000 may be too big.
20+
By example, if previous setting is true, NHibernate may try to use nvarchar2(4000),
21+
which will be rejected if its underlying charset is UTF16 and the database
22+
MAX_STRING_SIZE is not extended. In such case, reduce it to 2000. -->
23+
<property name="query.default_cast_length"></property>
1724
</session-factory>
1825
</hibernate-configuration>

src/NHibernate.Config.Templates/Oracle.cfg.xml

+7
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,12 @@ for your own use before compile tests in VisualStudio.
1414
<property name="show_sql">false</property>
1515
<property name="dialect">NHibernate.Dialect.OracleDialect</property>
1616
<property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
17+
<!-- If your database setup use an ASCII charset, switch following property to true. -->
18+
<property name="oracle.use_n_prefixed_types_for_unicode">false</property>
19+
<!-- Depending on your database setup, the default cast length of 4000 may be too big.
20+
By example, if previous setting is true, NHibernate may try to use nvarchar2(4000),
21+
which will be rejected if its underlying charset is UTF16 and the database
22+
MAX_STRING_SIZE is not extended. In such case, reduce it to 2000. -->
23+
<property name="query.default_cast_length"></property>
1724
</session-factory>
1825
</hibernate-configuration>

teamcity.build

+12
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@
127127
<property name="nhibernate.connection.connection_string" value="User ID=nhibernate;Password=nhibernate;Data Source=(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XE)))" />
128128
<!-- Teamcity Oracle test database is configured with a non-Unicode encoding -->
129129
<property name="nhibernate.oracle.use_n_prefixed_types_for_unicode" value="true" />
130+
<!-- The default value of 4000 is too big for nvarchar2 with default database settings.
131+
nvarchar2 may be used due to use_n_prefixed_types_for_unicode -->
132+
<property name="nhibernate.query.default_cast_length" value="2000" />
130133
<copy todir="${bin.dir}">
131134
<fileset basedir="${root.dir}/lib/teamcity/oracle/x86">
132135
<include name="*.dll"/>
@@ -143,6 +146,9 @@
143146
<property name="nhibernate.connection.connection_string" value="User ID=nhibernate;Password=nhibernate;Data Source=(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XE)))" />
144147
<!-- Teamcity Oracle test database is configured with a non-Unicode encoding -->
145148
<property name="nhibernate.oracle.use_n_prefixed_types_for_unicode" value="true" />
149+
<!-- The default value of 4000 is too big for nvarchar2 with default database settings.
150+
nvarchar2 may be used due to use_n_prefixed_types_for_unicode -->
151+
<property name="nhibernate.query.default_cast_length" value="2000" />
146152
<copy todir="${bin.dir}">
147153
<fileset basedir="${root.dir}/lib/teamcity/oracle/x64">
148154
<include name="*.dll"/>
@@ -158,6 +164,9 @@
158164
<property name="nhibernate.connection.connection_string" value="User ID=nhibernate;Password=nhibernate;Data Source=(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XE)))" />
159165
<!-- Teamcity Oracle test database is configured with a non-Unicode encoding -->
160166
<property name="nhibernate.oracle.use_n_prefixed_types_for_unicode" value="true" />
167+
<!-- The default value of 4000 is too big for nvarchar2 with default database settings.
168+
nvarchar2 may be used due to use_n_prefixed_types_for_unicode -->
169+
<property name="nhibernate.query.default_cast_length" value="2000" />
161170
</target>
162171

163172
<target name="setup-teamcity-oracle-managed64">
@@ -167,6 +176,9 @@
167176
<property name="nhibernate.connection.connection_string" value="User ID=nhibernate;Password=nhibernate;Data Source=(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XE)))" />
168177
<!-- Teamcity Oracle test database is configured with a non-Unicode encoding -->
169178
<property name="nhibernate.oracle.use_n_prefixed_types_for_unicode" value="true" />
179+
<!-- The default value of 4000 is too big for nvarchar2 with default database settings.
180+
nvarchar2 may be used due to use_n_prefixed_types_for_unicode -->
181+
<property name="nhibernate.query.default_cast_length" value="2000" />
170182
</target>
171183

172184
<target name="setup-teamcity-mysql">

0 commit comments

Comments
 (0)