Skip to content

Commit dcee301

Browse files
Merge branch 'master' into CacheBuild
2 parents 4d97ed1 + 8649f9a commit dcee301

File tree

205 files changed

+7868
-721
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

205 files changed

+7868
-721
lines changed

ShowBuildMenu.bat

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,14 @@ echo F. Add a test configuration for Oracle with managed driver.
5757
echo G. Add a test configuration for SQL Server Compact.
5858
echo H. Add a test configuration for MySql.
5959
echo I. Add a test configuration for SAP HANA.
60+
echo J. Add a test configuration for SAP SQL Anywhere.
6061
echo.
6162
echo X. Exit to main menu.
6263
echo.
6364

64-
%BUILDTOOL% prompt ABCDEFGHIX
65-
if errorlevel 9 goto main-menu
65+
%BUILDTOOL% prompt ABCDEFGHIJX
66+
if errorlevel 10 goto main-menu
67+
if errorlevel 9 goto test-setup-anywhere
6668
if errorlevel 8 goto test-setup-hana
6769
if errorlevel 7 goto test-setup-mysql
6870
if errorlevel 6 goto test-setup-sqlserverce
@@ -136,6 +138,13 @@ set LIB_FILES=
136138
set LIB_FILES2=
137139
goto test-setup-generic
138140

141+
:test-setup-anywhere
142+
set CONFIG_NAME=SapSQLAnywhere
143+
set TEST_PLATFORM=AnyCPU
144+
set LIB_FILES=
145+
set LIB_FILES2=
146+
goto test-setup-generic
147+
139148
:test-setup-generic
140149
set CFGNAME=
141150
set /p CFGNAME=Enter a name for your test configuration or press enter to use default name:
@@ -221,12 +230,14 @@ echo I. NHibernate Trunk - Oracle Managed (64-bit)
221230
echo J. NHibernate Trunk - SQL Server Compact (32-bit)
222231
echo K. NHibernate Trunk - SQL Server Compact (64-bit)
223232
echo L. NHibernate Trunk - SQL Server ODBC (32-bit)
233+
echo M. NHibernate Trunk - SAP SQL Anywhere
224234
echo.
225235
echo X. Exit to main menu.
226236
echo.
227237

228-
%BUILDTOOL% prompt ABCDEFGHIJKLX
229-
if errorlevel 12 goto main-menu
238+
%BUILDTOOL% prompt ABCDEFGHIJKLMX
239+
if errorlevel 13 goto main-menu
240+
if errorlevel 12 goto teamcity-anywhere
230241
if errorlevel 11 goto teamcity-sqlServerOdbc
231242
if errorlevel 10 goto teamcity-sqlServerCe64
232243
if errorlevel 9 goto teamcity-sqlServerCe32
@@ -312,5 +323,11 @@ move "%CURRENT_CONFIGURATION%" "%CURRENT_CONFIGURATION%-backup" 2> nul
312323
move "%CURRENT_CONFIGURATION%-backup" "%CURRENT_CONFIGURATION%" 2> nul
313324
goto main-menu
314325

326+
:teamcity-anywhere
327+
move "%CURRENT_CONFIGURATION%" "%CURRENT_CONFIGURATION%-backup" 2> nul
328+
%NANT% /f:teamcity.build -D:skip.manual=true -D:CCNetLabel=-1 -D:config.teamcity=sqlanywhere
329+
move "%CURRENT_CONFIGURATION%-backup" "%CURRENT_CONFIGURATION%" 2> nul
330+
goto main-menu
331+
315332
:end
316333
popd

doc/reference/modules/basic_mapping.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3364,8 +3364,8 @@
33643364
database column values to persistent classes that have identifier properties of the type specified by
33653365
<literal>id-type</literal>. If the meta-type is <literal>class</literal>, nothing else is required.
33663366
The class full name will be persisted in the database as the type of the associated entity.
3367-
On the other hand, if it is a basic type like <literal>string</literal> or
3368-
<literal>char</literal>, you must specify the mapping from values to classes.
3367+
On the other hand, if it is a basic type like <literal>int</literal> or <literal>char</literal>, you
3368+
must specify the mapping from values to classes. Here is an example with <literal>string</literal>.
33693369
</para>
33703370

33713371
<programlisting><![CDATA[<any name="being" id-type="long" meta-type="string">
@@ -3376,6 +3376,11 @@
33763376
<column name="id"/>
33773377
</any>]]></programlisting>
33783378

3379+
<para>
3380+
String types are a special case: they can be used without meta-values, in which case they will behave
3381+
much like the <literal>class</literal> meta-type.
3382+
</para>
3383+
33793384
<programlistingco>
33803385
<areaspec>
33813386
<area id="any1" coords="2 55"/>

doc/reference/modules/persistent_classes.xml

Lines changed: 60 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -254,60 +254,56 @@ namespace Eg
254254
<para>
255255
Persistent entities don't necessarily have to be represented as POCO classes
256256
at runtime. NHibernate also supports dynamic models
257-
(using <literal>Dictionaries</literal>). With this approach, you don't
258-
write persistent classes, only mapping files.
257+
(using <literal>Dictionaries</literal> or C# <literal>dynamic</literal>). With this approach,
258+
you don't write persistent classes, only mapping files.
259259
</para>
260260

261261
<para>
262-
The following examples demonstrates the representation using <literal>Dictionaries</literal>.
262+
The following examples demonstrates the dynamic model feature.
263263
First, in the mapping file, an <literal>entity-name</literal> has to be declared
264264
instead of a class name:
265265
</para>
266-
267-
<programlisting><![CDATA[<hibernate-mapping>
268266

267+
<programlisting><![CDATA[<hibernate-mapping>
269268
<class entity-name="Customer">
270-
271-
<id name="id"
269+
<id name="Id"
272270
type="long"
273271
column="ID">
274272
<generator class="sequence"/>
275273
</id>
276274
277-
<property name="name"
275+
<property name="Name"
278276
column="NAME"
279277
type="string"/>
280278
281-
<property name="address"
279+
<property name="Address"
282280
column="ADDRESS"
283281
type="string"/>
284282
285-
<many-to-one name="organization"
283+
<many-to-one name="Organization"
286284
column="ORGANIZATION_ID"
287285
class="Organization"/>
288286
289-
<bag name="orders"
287+
<bag name="Orders"
290288
inverse="true"
291289
lazy="false"
292290
cascade="all">
293291
<key column="CUSTOMER_ID"/>
294292
<one-to-many class="Order"/>
295293
</bag>
296-
297294
</class>
298-
299295
</hibernate-mapping>]]></programlisting>
300-
296+
301297
<para>
302298
Note that even though associations are declared using target class names,
303299
the target type of an associations may also be a dynamic entity instead
304300
of a POCO.
305301
</para>
306-
302+
307303
<para>
308304
At runtime we can work with <literal>Dictionaries</literal>:
309305
</para>
310-
306+
311307
<programlisting><![CDATA[using(ISession s = OpenSession())
312308
using(ITransaction tx = s.BeginTransaction())
313309
{
@@ -328,7 +324,32 @@ using(ITransaction tx = s.BeginTransaction())
328324
329325
tx.Commit();
330326
}]]></programlisting>
331-
327+
328+
<para>
329+
Or we can work with <literal>dynamic</literal>:
330+
</para>
331+
332+
<programlisting><![CDATA[using(var s = OpenSession())
333+
using(var tx = s.BeginTransaction())
334+
{
335+
// Create a customer
336+
dynamic frank = new ExpandoObject();
337+
frank.Name = "Frank";
338+
339+
// Create an organization
340+
dynamic foobar = new ExpandoObject();
341+
foobar.Name = "Foobar Inc.";
342+
343+
// Link both
344+
frank.Organization = foobar;
345+
346+
// Save both
347+
s.Save("Customer", frank);
348+
s.Save("Organization", foobar);
349+
350+
tx.Commit();
351+
}]]></programlisting>
352+
332353
<para>
333354
The advantages of a dynamic mapping are quick turnaround time for prototyping
334355
without the need for entity class implementation. However, you lose compile-time
@@ -338,8 +359,9 @@ using(ITransaction tx = s.BeginTransaction())
338359
</para>
339360

340361
<para>
341-
A loaded dynamic entity can be manipulated as an <literal>IDictionary</literal> or
342-
<literal>IDictionary&lt;string, object&gt;</literal>.
362+
A loaded dynamic entity can be manipulated as an <literal>IDictionary</literal>,
363+
an <literal>IDictionary&lt;string, object&gt;</literal> or a C#
364+
<literal>dynamic</literal>.
343365
</para>
344366

345367
<programlisting><![CDATA[using(ISession s = OpenSession())
@@ -350,8 +372,23 @@ using(ITransaction tx = s.BeginTransaction())
350372
.List<IDictionary<string, object>>();
351373
...
352374
}]]></programlisting>
375+
376+
<programlisting><![CDATA[using System.Linq.Dynamic.Core;
377+
378+
...
379+
380+
using(ISession s = OpenSession())
381+
using(ITransaction tx = s.BeginTransaction())
382+
{
383+
var customers = s
384+
.Query<dynamic>("Customer")
385+
.OrderBy("Name")
386+
.ToList();
387+
...
388+
}]]></programlisting>
389+
353390
</sect1>
354-
391+
355392
<sect1 id="persistent-classes-tuplizers" revision="1">
356393
<title>Tuplizers</title>
357394

@@ -371,9 +408,9 @@ using(ITransaction tx = s.BeginTransaction())
371408
</para>
372409

373410
<para>
374-
Users may also plug in their own tuplizers. Perhaps you require that a <literal>IDictionary</literal>
375-
implementation other than <literal>System.Collections.Generic.Dictionary&lt;string, object&gt;</literal>
376-
is used while in the dynamic-map entity-mode; or perhaps you need to define a different proxy generation strategy
411+
Users may also plug in their own tuplizers. Perhaps you require that a <literal>IDictionary</literal> /
412+
<literal>DynamicObject</literal> implementation other than NHibernate own implementation is used while
413+
in the dynamic-map entity-mode; or perhaps you need to define a different proxy generation strategy
377414
than the one used by default. Both would be achieved by defining a custom tuplizer
378415
implementation. Tuplizers definitions are attached to the entity or component mapping they
379416
are meant to manage. Going back to the example of our customer entity:
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Installation steps for SAP SQL Anywhere 17 for NH TeamCity:
2+
1. Download SAP SQL Anywhere 17 from https://www.sap.com/products/sql-anywhere.html.
3+
Please make sure you comply with it's license.
4+
5+
2. Run the installer
6+
3. Ensure the MSDTC Windows service is enabled. All transaction scope tests, even
7+
those normally not distributed, use it with SAP SQL Anywhere 17
8+
9+
The NHibernate.TestDatabaseSetup should normally do on its own the following operations:
10+
1. Create the test database with default options
11+
2. Run the query
12+
set option ansi_update_constraints = 'Off'
13+
(Otherwise some tests will fail.)
14+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
This template was written to work with NHibernate.Test.
4+
Copy the template to your NHibernate.Test project folder and rename it hibernate.cfg.xml. Change it
5+
for your own use before compiling tests in Visual Studio.
6+
-->
7+
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
8+
<session-factory name="NHibernate.Test">
9+
<property name="connection.driver_class">NHibernate.Driver.SapSQLAnywhere17Driver</property>
10+
<!-- Sap.Data.SQLAnywhere does not support re-enlisting in the same transaction, wrecking many usages
11+
with NHibernate when both NHibernate and the connection performs auto-enlistment. Setting
12+
"Enlist=false;" in the connection string solves this.
13+
It also requires to have the MSDTC service running, even for transaction scopes using a
14+
single connection. -->
15+
<property name="connection.connection_string">
16+
UID=DBA;PWD=sql;Server=localhost;DBN=nhibernate;DBF=c:\nhibernate.db;ASTOP=No;Enlist=false;
17+
</property>
18+
<property name="dialect">NHibernate.Dialect.SybaseSQLAnywhere12Dialect</property>
19+
<property name="query.substitutions">true=1;false=0</property>
20+
</session-factory>
21+
</hibernate-configuration>

src/NHibernate.DomainModel/ABCProxy.hbm.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
</id>
1111
<discriminator column="clazz_discriminata" type="Int32" force="true" not-null="false" />
1212
<property name="Name" />
13-
<many-to-one name="Forward" class="E" cascade="save-update" />
14-
13+
<many-to-one name="Forward" column="`Forward`" class="E" cascade="save-update" />
14+
1515
<subclass name="B" lazy="true" discriminator-value="null">
1616
<property name="Count" column="count_" type="Int32" />
1717
<map name="Map">
@@ -56,4 +56,4 @@
5656
<one-to-one name="Reverse" class="A" property-ref="Forward" cascade="save-update" />
5757
</class>
5858

59-
</hibernate-mapping>
59+
</hibernate-mapping>

src/NHibernate.DomainModel/Northwind/Mappings/Shipper.hbm.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<property name="PhoneNumber" column="Phone" type="string" length="24"
1515
access="field.camelcase-underscore"/>
1616

17-
<property name="Reference" column="Reference" type="guid" access="field.camelcase-underscore"/>
17+
<property name="Reference" column="`Reference`" type="guid" access="field.camelcase-underscore"/>
1818

1919
<bag name="Orders" lazy="true" access="field.camelcase-underscore"
2020
cascade="none">
@@ -24,4 +24,4 @@
2424

2525
</class>
2626

27-
</hibernate-mapping>
27+
</hibernate-mapping>

src/NHibernate.Test/Ado/GenericBatchingBatcherFixture.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ protected override bool AppliesTo(Dialect.Dialect dialect)
2929
return !(dialect is FirebirdDialect) &&
3030
!(dialect is Oracle8iDialect) &&
3131
!(dialect is MsSqlCeDialect) &&
32-
!(dialect is HanaDialectBase);
32+
!(dialect is HanaDialectBase) &&
33+
// A workaround exists for SQL Anywhere, see https://stackoverflow.com/a/32860293/1178314
34+
// It would imply some tweaking in the generic batcher. The same workaround could
35+
// be used for enabling future support.
36+
!(dialect is SybaseSQLAnywhere10Dialect);
3337
}
3438

3539
[Test]

src/NHibernate.Test/Async/Ado/GenericBatchingBatcherFixture.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ protected override bool AppliesTo(Dialect.Dialect dialect)
4242
return !(dialect is FirebirdDialect) &&
4343
!(dialect is Oracle8iDialect) &&
4444
!(dialect is MsSqlCeDialect) &&
45-
!(dialect is HanaDialectBase);
45+
!(dialect is HanaDialectBase) &&
46+
// A workaround exists for SQL Anywhere, see https://stackoverflow.com/a/32860293/1178314
47+
// It would imply some tweaking in the generic batcher. The same workaround could
48+
// be used for enabling future support.
49+
!(dialect is SybaseSQLAnywhere10Dialect);
4650
}
4751

4852
[Test]

src/NHibernate.Test/Async/CacheTest/SerializationFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ private object[] GetAllKnownTypeValues()
199199
{NHibernateUtil.TrueFalse, false},
200200
{NHibernateUtil.YesNo, true},
201201
{NHibernateUtil.Class, typeof(IType)},
202-
{NHibernateUtil.ClassMetaType, entityName},
202+
{NHibernateUtil.MetaType, entityName},
203203
{NHibernateUtil.Serializable, new MyEntity {Id = 1}},
204204
{NHibernateUtil.Object, new MyEntity {Id = 10}},
205205
{NHibernateUtil.AnsiChar, 'a'},

src/NHibernate.Test/Async/Component/Basic/ComponentWithUniqueConstraintTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ protected override HbmMapping GetMappings()
3232

3333
mapper.Component<Person>(comp =>
3434
{
35-
comp.Property(p => p.Name);
36-
comp.Property(p => p.Dob);
35+
comp.Property(p => p.Name, m => m.NotNullable(true));
36+
comp.Property(p => p.Dob, m => m.NotNullable(true));
3737
comp.Unique(true); // hbm2ddl: Generate a unique constraint in the database
3838
});
3939

@@ -94,9 +94,9 @@ public void CannotBePersistedWithNonUniqueValuesAsync()
9494
await (session.SaveAsync(e2));
9595
await (session.FlushAsync());
9696
});
97-
Assert.That(exception.InnerException, Is.AssignableTo<DbException>());
97+
Assert.That(exception.InnerException, Is.InstanceOf<DbException>());
9898
Assert.That(exception.InnerException.Message,
99-
Does.Contain("unique").IgnoreCase.And.Contains("constraint").IgnoreCase
99+
Does.Contain("unique").IgnoreCase
100100
.Or.Contains("duplicate entry").IgnoreCase);
101101
}
102102
}

src/NHibernate.Test/Async/Criteria/CriteriaQueryTest.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2719,6 +2719,9 @@ public async Task OrderProjectionTestAsync()
27192719
[Test]
27202720
public async Task OrderProjectionAliasedTestAsync()
27212721
{
2722+
if (TestDialect.HasBrokenTypeInferenceOnSelectedParameters)
2723+
Assert.Ignore("Current dialect does not support this test");
2724+
27222725
using (ISession session = OpenSession())
27232726
using (ITransaction t = session.BeginTransaction())
27242727
{

0 commit comments

Comments
 (0)