Skip to content

Commit 492c6d6

Browse files
NH-3488 - fix dialect dependent failures, first round, to be squashed.
1 parent ae397c2 commit 492c6d6

File tree

3 files changed

+786
-814
lines changed

3 files changed

+786
-814
lines changed

src/NHibernate.Test/Hql/Ast/BulkManipulation.cs

Lines changed: 47 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ namespace NHibernate.Test.Hql.Ast
1212
[TestFixture]
1313
public class BulkManipulation : BaseFixture
1414
{
15-
public ISession OpenNewSession()
16-
{
17-
return OpenSession();
18-
}
19-
2015
#region Non-exists
2116

2217
[Test]
@@ -932,6 +927,11 @@ public void DeleteOnDiscriminatorSubclass()
932927
[Test]
933928
public void DeleteOnJoinedSubclass()
934929
{
930+
if (!Dialect.SupportsTemporaryTables)
931+
{
932+
Assert.Ignore("Cannot perform multi-table deletes using dialect not supporting temp tables.");
933+
}
934+
935935
var data = new TestData(this);
936936
data.Prepare();
937937

@@ -956,6 +956,11 @@ public void DeleteOnJoinedSubclass()
956956
[Test]
957957
public void DeleteOnMappedJoin()
958958
{
959+
if (!Dialect.SupportsTemporaryTables)
960+
{
961+
Assert.Ignore("Cannot perform multi-table deletes using dialect not supporting temp tables.");
962+
}
963+
959964
var data = new TestData(this);
960965
data.Prepare();
961966

@@ -975,6 +980,11 @@ public void DeleteOnMappedJoin()
975980
[Test]
976981
public void DeleteUnionSubclassAbstractRoot()
977982
{
983+
if (!Dialect.SupportsTemporaryTables)
984+
{
985+
Assert.Ignore("Cannot perform multi-table deletes using dialect not supporting temp tables.");
986+
}
987+
978988
var data = new TestData(this);
979989
data.Prepare();
980990

@@ -997,6 +1007,11 @@ public void DeleteUnionSubclassAbstractRoot()
9971007
[Test]
9981008
public void DeleteUnionSubclassConcreteSubclass()
9991009
{
1010+
if (!Dialect.SupportsTemporaryTables)
1011+
{
1012+
Assert.Ignore("Cannot perform multi-table deletes using dialect not supporting temp tables.");
1013+
}
1014+
10001015
var data = new TestData(this);
10011016
data.Prepare();
10021017

@@ -1040,6 +1055,11 @@ public void DeleteUnionSubclassLeafSubclass()
10401055
[Test]
10411056
public void DeleteRestrictedOnManyToOne()
10421057
{
1058+
if (!Dialect.SupportsTemporaryTables)
1059+
{
1060+
Assert.Ignore("Cannot perform multi-table deletes using dialect not supporting temp tables.");
1061+
}
1062+
10431063
var data = new TestData(this);
10441064
data.Prepare();
10451065

@@ -1089,7 +1109,7 @@ public TestData(BulkManipulation tc)
10891109

10901110
public void Prepare()
10911111
{
1092-
ISession s = tc.OpenNewSession();
1112+
ISession s = tc.OpenSession();
10931113
ITransaction txn = s.BeginTransaction();
10941114

10951115
Polliwog = new Animal {BodyWeight = 12, Description = "Polliwog"};
@@ -1152,19 +1172,27 @@ public void Prepare()
11521172

11531173
public void Cleanup()
11541174
{
1155-
ISession s = tc.OpenNewSession();
1156-
ITransaction txn = s.BeginTransaction();
1157-
1158-
// workaround awesome HSQLDB "feature"
1159-
s.CreateQuery("delete from Animal where mother is not null or father is not null").ExecuteUpdate();
1160-
s.CreateQuery("delete from Animal").ExecuteUpdate();
1161-
s.CreateQuery("delete from Zoo").ExecuteUpdate();
1162-
s.CreateQuery("delete from Joiner").ExecuteUpdate();
1163-
s.CreateQuery("delete from Vehicle").ExecuteUpdate();
1164-
s.CreateQuery("delete from BooleanLiteralEntity").ExecuteUpdate();
1165-
1166-
txn.Commit();
1167-
s.Close();
1175+
if (!tc.Dialect.SupportsTemporaryTables)
1176+
{
1177+
// Give-up usual cleanup due to TPC: cannot perform multi-table deletes using dialect not supporting temp tables
1178+
tc.DropSchema();
1179+
tc.CreateSchema();
1180+
return;
1181+
}
1182+
using (var s = tc.OpenSession())
1183+
using (var txn = s.BeginTransaction())
1184+
{
1185+
// workaround awesome HSQLDB "feature"
1186+
s.CreateQuery("delete from Animal where mother is not null or father is not null").ExecuteUpdate();
1187+
s.CreateQuery("delete from Animal").ExecuteUpdate();
1188+
s.CreateQuery("delete from Zoo").ExecuteUpdate();
1189+
s.CreateQuery("delete from Joiner").ExecuteUpdate();
1190+
s.CreateQuery("delete from Vehicle").ExecuteUpdate();
1191+
s.CreateQuery("delete from BooleanLiteralEntity").ExecuteUpdate();
1192+
1193+
txn.Commit();
1194+
s.Close();
1195+
}
11681196
}
11691197
}
11701198
}

src/NHibernate.Test/NHSpecificTest/NH3488/Domain/EntityWithCrazyCompositeKey.hbm.xml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
assembly="NHibernate.Test"
44
namespace="NHibernate.Test.NHSpecificTest.NH3488.Domain">
55

6-
<class name="EntityWithCrazyCompositeKey">
7-
<composite-id name="Id" class="CrazyCompositeKey">
8-
<key-property name="Id" column="id"/>
9-
<key-property name="OtherId" column="other_id"/>
10-
</composite-id>
11-
<property name="Name"/>
6+
<class name="EntityWithCrazyCompositeKey">
7+
<composite-id name="Id" class="CrazyCompositeKey">
8+
<key-property name="Id" column="id"/>
9+
<key-property name="OtherId" column="other_id"/>
10+
</composite-id>
11+
<property name="Name"/>
1212
</class>
13-
14-
<class name="EntityReferencingEntityWithCrazyCompositeKey">
13+
14+
<!-- Oracle and Firebird does not allow names longer than 30 characters.-->
15+
<class name="EntityReferencingEntityWithCrazyCompositeKey" table="EntRefEntWithCrazyCompKey">
1516
<id type="long" name="Id">
1617
<generator class="native" />
1718
</id>

0 commit comments

Comments
 (0)