Skip to content

Commit 2508020

Browse files
committed
feat!: upgrade to NHibernate 4
1 parent cf6781c commit 2508020

17 files changed

+70
-61
lines changed

src/NHibernate.Search.Tests/DebugConnectionProvider.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections;
3+
using System.Collections.Generic;
34
using System.Data;
45
using Iesi.Collections;
56
using NHibernate.Connection;
@@ -12,7 +13,7 @@ namespace NHibernate.Test
1213
/// </summary>
1314
public class DebugConnectionProvider : DriverConnectionProvider
1415
{
15-
private ISet connections = new ListSet();
16+
private readonly ISet<IDbConnection> connections = new HashSet<IDbConnection>();
1617

1718
public override IDbConnection GetConnection()
1819
{
@@ -34,7 +35,7 @@ public bool HasOpenConnections
3435
// check to see if all connections that were at one point opened
3536
// have been closed through the CloseConnection
3637
// method
37-
if (connections.IsEmpty)
38+
if (connections.Count == 0)
3839
{
3940
// there are no connections, either none were opened or
4041
// all of the closings went through CloseConnection.
@@ -62,7 +63,7 @@ public bool HasOpenConnections
6263

6364
public void CloseAllConnections()
6465
{
65-
while (!connections.IsEmpty)
66+
while (connections.Count != 0)
6667
{
6768
IEnumerator en = connections.GetEnumerator();
6869
if (en.MoveNext())

src/NHibernate.Search.Tests/Embedded/Address.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Collections.Generic;
12
using Iesi.Collections.Generic;
23
using NHibernate.Search.Attributes;
34

@@ -19,7 +20,7 @@ public class Address
1920
private string street;
2021

2122
[ContainedIn]
22-
private ISet<Tower> towers = new HashedSet<Tower>();
23+
private ISet<Tower> towers = new HashSet<Tower>();
2324

2425
public virtual long Id
2526
{

src/NHibernate.Search.Tests/Embedded/DoubleInsert/Contact.cs

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

34
namespace NHibernate.Search.Tests.Embedded.DoubleInsert
45
{
@@ -26,8 +27,8 @@ public class Contact
2627

2728
public Contact()
2829
{
29-
addresses = new HashedSet<Address>();
30-
phoneNumbers = new HashedSet<Phone>();
30+
addresses = new HashSet<Address>();
31+
phoneNumbers = new HashSet<Phone>();
3132
}
3233

3334
#endregion

src/NHibernate.Search.Tests/Embedded/IndexedEmbeddedAndCollections.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,13 @@ public void CanLookupEntityByValueOfEmbeddedSetValues()
110110
Assert.AreEqual(1, result.Count, "collection of embedded (set) ignored");
111111
}
112112

113-
[Test]
113+
[Test, Explicit("many-to-many is not supported")]
114114
public void CanLookupEntityByValueOfEmbeddedDictionaryValue()
115115
{
116116
IFullTextSession session = Search.CreateFullTextSession(s);
117117

118118
// PhraseQuery
119-
TermQuery query = new TermQuery(new Term("orders.orderNumber", "ZERTYD"));
119+
TermQuery query = new TermQuery(new Term("orders.value.orderNumber", "ZERTYD"));
120120
IList result = session.CreateFullTextQuery(query, typeof(Product)).List();
121121
Assert.AreEqual(1, result.Count, "collection of untokenized ignored");
122122

src/NHibernate.Search.Tests/Embedded/Product.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ public class Product
1313
[Field(Index.Tokenized)]
1414
private string name;
1515
[IndexedEmbedded]
16-
private Iesi.Collections.Generic.ISet<Author> authors = new HashedSet<Author>();
17-
[IndexedEmbedded]
16+
private ISet<Author> authors = new HashSet<Author>();
17+
//[IndexedEmbedded]
1818
private IDictionary<string, Order> orders = new Dictionary<string, Order>();
1919

2020
public virtual int Id
@@ -29,7 +29,7 @@ public virtual string Name
2929
set { name = value; }
3030
}
3131

32-
public virtual Iesi.Collections.Generic.ISet<Author> Authors
32+
public virtual ISet<Author> Authors
3333
{
3434
get { return authors; }
3535
set { authors = value; }

src/NHibernate.Search.Tests/Query/Book.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using Iesi.Collections.Generic;
34
using NHibernate.Search.Attributes;
45

@@ -10,7 +11,7 @@ public class Book
1011
private int id;
1112
private String summary;
1213
private String body;
13-
private ISet<Author> authors = new HashedSet<Author>();
14+
private ISet<Author> authors = new HashSet<Author>();
1415
private Author mainAuthor;
1516
private DateTime publicationDate;
1617

src/NHibernate.Search.Tests/Query/Music.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Collections.Generic;
12
using Iesi.Collections.Generic;
23
using NHibernate.Search.Attributes;
34

@@ -8,7 +9,7 @@ public class Music
89
{
910
private long id;
1011
private string title;
11-
private ISet<Author> authors = new HashedSet<Author>();
12+
private ISet<Author> authors = new HashSet<Author>();
1213

1314
[DocumentId]
1415
public virtual long Id

src/NHibernate.Search/Engine/DocumentBuilder.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Collections;
33
using System.Collections.Generic;
44
using System.Globalization;
5-
using Iesi.Collections.Generic;
65
using Lucene.Net.Analysis;
76
using Lucene.Net.Documents;
87
using Lucene.Net.Index;
@@ -33,7 +32,7 @@ public class DocumentBuilder
3332
private readonly IIndexShardingStrategy shardingStrategy;
3433
private readonly ScopedAnalyzer analyzer;
3534
private DocumentIdMapping idMapping;
36-
private Iesi.Collections.Generic.ISet<Type> mappedSubclasses = new HashedSet<System.Type>();
35+
private ISet<Type> mappedSubclasses = new HashSet<System.Type>();
3736

3837
private readonly DocumentMapping rootClassMapping;
3938

@@ -50,7 +49,7 @@ public DocumentBuilder(DocumentMapping classMapping, Analyzer defaultAnalyzer, I
5049

5150
rootClassMapping = classMapping;
5251

53-
Set<System.Type> processedClasses = new HashedSet<System.Type>();
52+
ISet<System.Type> processedClasses = new HashSet<System.Type>();
5453
processedClasses.Add(classMapping.MappedClass);
5554
CollectAnalyzers(rootClassMapping, defaultAnalyzer, true, string.Empty, processedClasses);
5655
//processedClasses.remove( clazz ); for the sake of completness
@@ -83,7 +82,7 @@ public ITwoWayFieldBridge IdBridge
8382
get { return idMapping.Bridge; }
8483
}
8584

86-
public Iesi.Collections.Generic.ISet<System.Type> MappedSubclasses
85+
public ISet<System.Type> MappedSubclasses
8786
{
8887
get { return mappedSubclasses; }
8988
}
@@ -243,11 +242,11 @@ public static object[] GetDocumentFields(ISearchFactoryImplementor searchFactory
243242
return result;
244243
}
245244

246-
public void PostInitialize(Iesi.Collections.Generic.ISet<System.Type> indexedClasses)
245+
public void PostInitialize(ISet<System.Type> indexedClasses)
247246
{
248247
// this method does not requires synchronization
249248
Type plainClass = rootClassMapping.MappedClass;
250-
Iesi.Collections.Generic.ISet<Type> tempMappedSubclasses = new HashedSet<System.Type>();
249+
ISet<Type> tempMappedSubclasses = new HashSet<System.Type>();
251250

252251
// together with the caller this creates a o(2), but I think it's still faster than create the up hierarchy for each class
253252
foreach (Type currentClass in indexedClasses)
@@ -338,9 +337,9 @@ private void BuildDocumentFieldsForEmbedded(EmbeddedMapping embeddedMapping, obj
338337
try
339338
{
340339
prefix += embeddedMapping.Prefix;
341-
if (value is IDictionary)
340+
if (value is IDictionary dictionary)
342341
{
343-
foreach (object collectionValue in (value as IDictionary).Values)
342+
foreach (object collectionValue in dictionary.Values)
344343
{
345344
BuildDocumentFields(collectionValue, doc, embeddedMapping.Class, prefix);
346345
}
@@ -412,7 +411,7 @@ private static Field.Store GetStore(Attributes.Store store)
412411
}
413412

414413
private void CollectAnalyzers(
415-
DocumentMapping @class, Analyzer parentAnalyzer, bool isRoot, string prefix, Iesi.Collections.Generic.ISet<System.Type> processedClasses
414+
DocumentMapping @class, Analyzer parentAnalyzer, bool isRoot, string prefix, ISet<System.Type> processedClasses
416415
)
417416
{
418417
foreach (var bridge in @class.ClassBridges)

src/NHibernate.Search/Impl/FullTextSessionImpl.cs

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,13 @@ public void Save(object obj, object id)
239239
public object Save(string entityName, object obj)
240240
{
241241
return session.Save(entityName, obj);
242-
}
243-
242+
}
243+
244+
public void Save(string entityName, object obj, object id)
245+
{
246+
session.Save(entityName, obj, id);
247+
}
248+
244249
public void SaveOrUpdate(object obj)
245250
{
246251
session.SaveOrUpdate(obj);
@@ -249,8 +254,13 @@ public void SaveOrUpdate(object obj)
249254
public void SaveOrUpdate(string entityName, object obj)
250255
{
251256
session.SaveOrUpdate(entityName, obj);
252-
}
253-
257+
}
258+
259+
public void SaveOrUpdate(string entityName, object obj, object id)
260+
{
261+
session.SaveOrUpdate(entityName, obj, id);
262+
}
263+
254264
public void Update(object obj)
255265
{
256266
session.Update(obj);
@@ -264,8 +274,13 @@ public void Update(object obj, object id)
264274
public void Update(string entityName, object obj)
265275
{
266276
session.Update(entityName, obj);
267-
}
268-
277+
}
278+
279+
public void Update(string entityName, object obj, object id)
280+
{
281+
session.Update(entityName, obj, id);
282+
}
283+
269284
public object Merge(object obj)
270285
{
271286
return session.Merge(obj);
@@ -296,18 +311,6 @@ public void Persist(string entityName, object obj)
296311
session.Persist(entityName, obj);
297312
}
298313

299-
[Obsolete("Use Merge(object) instead")]
300-
public object SaveOrUpdateCopy(object obj)
301-
{
302-
return session.SaveOrUpdateCopy(obj);
303-
}
304-
305-
[Obsolete("Use Merge(object) instead")]
306-
public object SaveOrUpdateCopy(object obj, object id)
307-
{
308-
return session.SaveOrUpdateCopy(obj, id);
309-
}
310-
311314
public void Delete(object obj)
312315
{
313316
session.Delete(obj);

src/NHibernate.Search/Impl/SearchFactoryImpl.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ private SearchFactoryImpl(Configuration cfg)
6767
Analyzer analyzer = InitAnalyzer(cfg);
6868
InitDocumentBuilders(cfg, analyzer);
6969

70-
Iesi.Collections.Generic.ISet<System.Type> classes = new HashedSet<System.Type>(documentBuilders.Keys);
70+
ISet<System.Type> classes = new HashSet<System.Type>(documentBuilders.Keys);
7171
foreach (DocumentBuilder documentBuilder in documentBuilders.Values)
7272
documentBuilder.PostInitialize(classes);
7373
worker = WorkerFactory.CreateWorker(cfg, this);

0 commit comments

Comments
 (0)