Skip to content

Commit 600c5b5

Browse files
committed
Remove support for persistent non-generic maps.
1 parent 511e4bf commit 600c5b5

25 files changed

+336
-944
lines changed

src/NHibernate.DomainModel/Fum.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Collections;
32
using System.Collections.Generic;
43
using NHibernate.Classic;
54

@@ -8,11 +7,11 @@ namespace NHibernate.DomainModel
87
[Serializable]
98
public class MapComponent
109
{
11-
private IDictionary _fummap = new Hashtable();
12-
private IDictionary _stringmap = new Hashtable();
10+
private IDictionary<string, Fum> _fummap = new Dictionary<string, Fum>();
11+
private IDictionary<string, string> _stringmap = new Dictionary<string, string>();
1312
private int _count;
1413

15-
public IDictionary Fummap
14+
public IDictionary<string, Fum> Fummap
1615
{
1716
get { return _fummap; }
1817
set { _fummap = value; }
@@ -24,7 +23,7 @@ public int Count
2423
set { _count = value; }
2524
}
2625

27-
public IDictionary Stringmap
26+
public IDictionary<string, string> Stringmap
2827
{
2928
get { return _stringmap; }
3029
set { _stringmap = value; }

src/NHibernate.Test/CollectionTest/NullableValueTypeElementMapFixture.cs

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -163,65 +163,5 @@ public void ShouldAddAndRemoveNullElements()
163163
Assert.That(parent.TypedDates[2], Is.Null);
164164
}
165165
}
166-
167-
[Test]
168-
public void AddRemoveUntypedElements()
169-
{
170-
Guid parentId;
171-
var date = new DateTime(2010, 09, 08);
172-
173-
int toBeRemoved = 0;
174-
int toBeUpdatedToNull = 1;
175-
int toRemainNull = 2;
176-
int toBeUpdatedFromNull = 3;
177-
int toBeAddedNull = 4;
178-
int toBeAddedNotNull = 5;
179-
180-
using (var s = OpenSession())
181-
using (var tx = s.BeginTransaction())
182-
{
183-
var parent = new Parent();
184-
parent.UntypedDates[toBeRemoved] = null;
185-
parent.UntypedDates[toBeUpdatedToNull] = date;
186-
parent.UntypedDates[toRemainNull] = null;
187-
parent.UntypedDates[toBeUpdatedFromNull] = null;
188-
189-
s.Save(parent);
190-
parentId = parent.Id;
191-
tx.Commit();
192-
}
193-
194-
using (var s = OpenSession())
195-
using (var tx = s.BeginTransaction())
196-
{
197-
var parent = s.Load<Parent>(parentId);
198-
199-
Assert.That(parent.UntypedDates.Count, Is.EqualTo(4));
200-
Assert.That(parent.UntypedDates[toBeRemoved], Is.Null);
201-
Assert.That(parent.UntypedDates[toBeUpdatedToNull], Is.EqualTo(date));
202-
Assert.That(parent.UntypedDates[toRemainNull], Is.Null);
203-
Assert.That(parent.UntypedDates[toBeUpdatedFromNull], Is.Null);
204-
205-
parent.UntypedDates.Remove(toBeRemoved);
206-
parent.UntypedDates[toBeUpdatedToNull] = null;
207-
parent.UntypedDates[toBeUpdatedFromNull] = date;
208-
parent.UntypedDates[toBeAddedNull] = null;
209-
parent.UntypedDates[toBeAddedNotNull] = date;
210-
tx.Commit();
211-
}
212-
213-
using (var s = OpenSession())
214-
using (var tx = s.BeginTransaction())
215-
{
216-
var parent = s.Load<Parent>(parentId);
217-
218-
Assert.That(parent.UntypedDates.Count, Is.EqualTo(5));
219-
Assert.That(parent.UntypedDates[toBeUpdatedToNull], Is.Null);
220-
Assert.That(parent.UntypedDates[toRemainNull], Is.Null);
221-
Assert.That(parent.UntypedDates[toBeUpdatedFromNull], Is.EqualTo(date));
222-
Assert.That(parent.UntypedDates[toBeAddedNull], Is.Null);
223-
Assert.That(parent.UntypedDates[toBeAddedNotNull], Is.EqualTo(date));
224-
}
225-
}
226166
}
227167
}

src/NHibernate.Test/CollectionTest/NullableValueTypeElementMapFixture.hbm.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,5 @@
99
<index column="Idx" type="int" />
1010
<element column="`Value`" />
1111
</map>
12-
<map name="UntypedDates">
13-
<key column="ParentId" />
14-
<index column="Idx" type="int" />
15-
<element column="`Value`" type="System.Nullable`1[[System.DateTime, mscorlib]]" />
16-
</map>
1712
</class>
1813
</hibernate-mapping>
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Collections;
32
using System.Collections.Generic;
43

54
namespace NHibernate.Test.CollectionTest
@@ -8,12 +7,10 @@ public class Parent
87
{
98
public virtual Guid Id { get; set; }
109
public virtual IDictionary<int, DateTime?> TypedDates { get; set; }
11-
public virtual IDictionary UntypedDates { get; set; }
1210

1311
public Parent()
1412
{
1513
TypedDates = new Dictionary<int, DateTime?>();
16-
UntypedDates = new Hashtable();
1714
}
1815
}
1916
}

src/NHibernate.Test/Extralazy/ExtraLazyFixture.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections;
2+
using System.Collections.Generic;
23
using NUnit.Framework;
34

45
namespace NHibernate.Test.Extralazy
@@ -134,10 +135,10 @@ public void Get()
134135
turin = (User) g.Users["turin"];
135136
Assert.That(gavin, Is.Not.Null);
136137
Assert.That(turin, Is.Not.Null);
137-
Assert.That(g.Users["emmanuel"], Is.Null);
138+
Assert.That(g.Users.ContainsKey("emmanuel"), Is.False);
138139
Assert.IsFalse(NHibernateUtil.IsInitialized(g.Users));
139140
Assert.That(gavin.Session["foo"], Is.Not.Null);
140-
Assert.That(turin.Session["foo"], Is.Null);
141+
Assert.That(turin.Session.ContainsKey("foo"), Is.False);
141142
Assert.IsFalse(NHibernateUtil.IsInitialized(gavin.Session));
142143
Assert.IsFalse(NHibernateUtil.IsInitialized(turin.Session));
143144
s.Delete(gavin);
@@ -189,7 +190,7 @@ public void RemoveClear()
189190
//Assert.IsTrue( g.Users.IsEmpty() );
190191
//Assert.IsFalse( NHibernateUtil.IsInitialized( g.getUsers() ) );
191192
gavin = s.Get<User>("gavin");
192-
Assert.IsFalse(gavin.Session.Contains("foo"));
193+
Assert.IsFalse(gavin.Session.ContainsKey("foo"));
193194
Assert.IsFalse(NHibernateUtil.IsInitialized(gavin.Session));
194195
s.Delete(gavin);
195196
s.Delete(turin);
@@ -204,7 +205,7 @@ public void IndexFormulaMap()
204205
User gavin = null;
205206
User turin = null;
206207
Group g = null;
207-
IDictionary smap = null;
208+
IDictionary<string, SessionAttribute> smap = null;
208209

209210
using (var s = OpenSession())
210211
using (var t = s.BeginTransaction())
Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
1-
using System.Collections;
1+
using System.Collections.Generic;
22

33
namespace NHibernate.Test.Extralazy
44
{
55
public class Group
66
{
7-
private string name;
8-
private IDictionary users = new Hashtable();
7+
private string _name;
8+
private IDictionary<string, User> _users = new Dictionary<string, User>();
9+
910
protected Group() {}
1011
public Group(string name)
1112
{
12-
this.name = name;
13+
this._name = name;
1314
}
1415

1516
public virtual string Name
1617
{
17-
get { return name; }
18-
set { name = value; }
18+
get { return _name; }
19+
set { _name = value; }
1920
}
2021

21-
public virtual IDictionary Users
22+
public virtual IDictionary<string, User> Users
2223
{
23-
get { return users; }
24-
set { users = value; }
24+
get { return _users; }
25+
set { _users = value; }
2526
}
2627
}
2728
}

src/NHibernate.Test/Extralazy/User.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.Collections;
21
using System.Collections.Generic;
32

43
namespace NHibernate.Test.Extralazy
@@ -7,7 +6,7 @@ public class User
76
{
87
private string name;
98
private string password;
10-
private IDictionary session = new Hashtable();
9+
private IDictionary<string, SessionAttribute> session = new Dictionary<string, SessionAttribute>();
1110
private ISet<Document> documents = new HashSet<Document>();
1211
private ISet<Photo> photos = new HashSet<Photo>();
1312
protected User() {}
@@ -29,7 +28,7 @@ public virtual string Password
2928
set { password = value; }
3029
}
3130

32-
public virtual IDictionary Session
31+
public virtual IDictionary<string, SessionAttribute> Session
3332
{
3433
get { return session; }
3534
set { session = value; }

src/NHibernate.Test/Hql/Ast/Animal.hbm.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@
107107
</id>
108108
<discriminator column="zooType" type="character"/>
109109
<property name="name" type="string"/>
110-
<property name="classification"/>
111-
<map name="mammals">
110+
<property name="classification"/>
111+
<map name="mammals">
112112
<key column="mammalZoo_id"/>
113113
<index type="string" column="name"/>
114114
<one-to-many class="Mammal"/>

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class Human: Mammal
99
private string nickName;
1010
private ICollection friends;
1111
private ICollection pets;
12-
private IDictionary family;
12+
private IDictionary<string, Human> family;
1313
private double height;
1414

1515
private long bigIntegerValue;
@@ -18,7 +18,7 @@ public class Human: Mammal
1818
private float floatValue;
1919

2020
private ISet<string> nickNames;
21-
private IDictionary addresses;
21+
private IDictionary<string, Address> addresses;
2222

2323
public virtual Name Name
2424
{
@@ -44,7 +44,7 @@ public virtual ICollection Pets
4444
set { pets = value; }
4545
}
4646

47-
public virtual IDictionary Family
47+
public virtual IDictionary<string, Human> Family
4848
{
4949
get { return family; }
5050
set { family = value; }
@@ -86,7 +86,7 @@ public virtual ISet<string> NickNames
8686
set { nickNames = value; }
8787
}
8888

89-
public virtual IDictionary Addresses
89+
public virtual IDictionary<string, Address> Addresses
9090
{
9191
get { return addresses; }
9292
set { addresses = value; }

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections;
2+
using System.Collections.Generic;
23

34
namespace NHibernate.Test.Hql.Ast
45
{
@@ -7,8 +8,8 @@ public class Zoo
78
private long id;
89
private string name;
910
private Classification classification;
10-
private IDictionary animals;
11-
private IDictionary mammals;
11+
private IDictionary<string, Animal> animals;
12+
private IDictionary<string, Mammal> mammals;
1213
private Address address;
1314

1415
public virtual long Id
@@ -29,13 +30,13 @@ public virtual Classification Classification
2930
set { classification = value; }
3031
}
3132

32-
public virtual IDictionary Animals
33+
public virtual IDictionary<string, Animal> Animals
3334
{
3435
get { return animals; }
3536
set { animals = value; }
3637
}
3738

38-
public virtual IDictionary Mammals
39+
public virtual IDictionary<string, Mammal> Mammals
3940
{
4041
get { return mammals; }
4142
set { mammals = value; }

0 commit comments

Comments
 (0)