Skip to content

Commit 7ffa17a

Browse files
authored
Merge pull request #637 from fredericDelaporte/NH-4017-2
NH-4023 - Passing session to type getter and setter
2 parents ab42cdc + 63991c1 commit 7ffa17a

File tree

74 files changed

+406
-463
lines changed

Some content is hidden

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

74 files changed

+406
-463
lines changed

src/NHibernate.DomainModel/NHSpecific/NullInt32UserType.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
22
using System.Data.Common;
3-
3+
using NHibernate.Engine;
44
using NHibernate.SqlTypes;
55
using NHibernate.Type;
66
using NHibernate.UserTypes;
@@ -46,15 +46,15 @@ public object DeepCopy(object value)
4646
return value;
4747
}
4848

49-
public void NullSafeSet(DbCommand cmd, object value, int index)
49+
public void NullSafeSet(DbCommand cmd, object value, int index, ISessionImplementor session)
5050
{
5151
if (value.Equals(0))
5252
{
5353
cmd.Parameters[index].Value = DBNull.Value;
5454
}
5555
else
5656
{
57-
_int32Type.Set(cmd, value, index);
57+
_int32Type.Set(cmd, value, index, session);
5858
}
5959
}
6060

@@ -63,9 +63,9 @@ public System.Type ReturnedType
6363
get { return typeof(Int32); }
6464
}
6565

66-
public object NullSafeGet(DbDataReader rs, string[] names, object owner)
66+
public object NullSafeGet(DbDataReader rs, string[] names, ISessionImplementor session, object owner)
6767
{
68-
return _int32Type.NullSafeGet(rs, names);
68+
return _int32Type.NullSafeGet(rs, names, session);
6969
}
7070

7171
public bool IsMutable

src/NHibernate.DomainModel/NHSpecific/NullableInt32Type.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
22
using System.Data.Common;
3-
3+
using NHibernate.Engine;
44
using NHibernate.SqlTypes;
55
using NHibernate.Type;
66

@@ -26,12 +26,12 @@ public override System.Type ReturnedClass
2626
get { return typeof(NullableInt32); }
2727
}
2828

29-
public override object Get(DbDataReader rs, int index)
29+
public override object Get(DbDataReader rs, int index, ISessionImplementor session)
3030
{
3131
return new NullableInt32(Convert.ToInt32(rs[index]));
3232
}
3333

34-
public override void Set(DbCommand cmd, object value, int index)
34+
public override void Set(DbCommand cmd, object value, int index, ISessionImplementor session)
3535
{
3636
var parameter = cmd.Parameters[index];
3737
NullableInt32 nullableValue = (NullableInt32) value;

src/NHibernate.DomainModel/NHSpecific/NullableTypesType.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
22
using System.Data.Common;
3-
3+
using NHibernate.Engine;
44
using NHibernate.SqlTypes;
55
using NHibernate.Type;
66

@@ -17,9 +17,9 @@ public NullableTypesType(SqlType type) : base(type)
1717
{
1818
}
1919

20-
public override object NullSafeGet(DbDataReader rs, string name)
20+
public override object NullSafeGet(DbDataReader rs, string name, ISessionImplementor session)
2121
{
22-
object value = base.NullSafeGet(rs, name);
22+
object value = base.NullSafeGet(rs, name, session);
2323
if (value == null)
2424
{
2525
return NullValue;
@@ -30,9 +30,9 @@ public override object NullSafeGet(DbDataReader rs, string name)
3030
}
3131
}
3232

33-
public override object Get(DbDataReader rs, string name)
33+
public override object Get(DbDataReader rs, string name, ISessionImplementor session)
3434
{
35-
return Get(rs, rs.GetOrdinal(name));
35+
return Get(rs, rs.GetOrdinal(name), session);
3636
}
3737

3838
public override string ToString(object value)

src/NHibernate.DomainModel/Northwind/Entities/User.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Data.Common;
3+
using NHibernate.Engine;
34
using NHibernate.Type;
45

56
namespace NHibernate.DomainModel.Northwind.Entities
@@ -71,17 +72,17 @@ public class EnumStoredAsStringType : EnumStringType
7172
public EnumStoredAsStringType()
7273
: base(typeof(EnumStoredAsString), 12) { }
7374

74-
public override void Set(DbCommand cmd, object value, int index)
75+
public override void Set(DbCommand cmd, object value, int index, ISessionImplementor session)
7576
{
7677
if (value is EnumStoredAsString && (EnumStoredAsString)value == EnumStoredAsString.Unspecified)
77-
base.Set(cmd, null, index);
78+
base.Set(cmd, null, index, session);
7879
else
79-
base.Set(cmd, value, index);
80+
base.Set(cmd, value, index, session);
8081
}
8182

82-
public override object Get(DbDataReader rs, int index)
83+
public override object Get(DbDataReader rs, int index, ISessionImplementor session)
8384
{
84-
object obj = base.Get(rs, index);
85+
object obj = base.Get(rs, index, session);
8586
if (obj == null) return EnumStoredAsString.Unspecified;
8687
return obj;
8788
}

src/NHibernate.Test/DateTimeOffsetUserType.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Data;
33
using System.Data.Common;
4+
using NHibernate.Engine;
45
using NHibernate.SqlTypes;
56
using NHibernate.UserTypes;
67

@@ -29,7 +30,7 @@ public SqlType[] SqlTypes
2930
get { return new[] { new SqlType(DbType.DateTime) }; }
3031
}
3132

32-
public object NullSafeGet(DbDataReader dr, string[] names, object owner)
33+
public object NullSafeGet(DbDataReader dr, string[] names, ISessionImplementor session, object owner)
3334
{
3435
var name = names[0];
3536
int index = dr.GetOrdinal(name);
@@ -39,7 +40,7 @@ public object NullSafeGet(DbDataReader dr, string[] names, object owner)
3940
return null;
4041
}
4142
try
42-
{
43+
{
4344
DateTime storedTime;
4445
try
4546
{
@@ -62,11 +63,11 @@ public object NullSafeGet(DbDataReader dr, string[] names, object owner)
6263
}
6364
}
6465

65-
public void NullSafeSet(DbCommand cmd, object value, int index)
66+
public void NullSafeSet(DbCommand cmd, object value, int index, ISessionImplementor session)
6667
{
6768
if (value == null)
6869
{
69-
NHibernateUtil.DateTime.NullSafeSet(cmd, null, index);
70+
NHibernateUtil.DateTime.NullSafeSet(cmd, null, index, session);
7071
}
7172
else
7273
{

src/NHibernate.Test/MappingByCode/MappersTests/PropertyMapperTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,12 +334,12 @@ public int GetHashCode(object x)
334334
throw new NotImplementedException();
335335
}
336336

337-
public object NullSafeGet(DbDataReader rs, string[] names, object owner)
337+
public object NullSafeGet(DbDataReader rs, string[] names, ISessionImplementor session, object owner)
338338
{
339339
throw new NotImplementedException();
340340
}
341341

342-
public void NullSafeSet(DbCommand cmd, object value, int index)
342+
public void NullSafeSet(DbCommand cmd, object value, int index, ISessionImplementor session)
343343
{
344344
throw new NotImplementedException();
345345
}

src/NHibernate.Test/NHSpecificTest/DataReaderWrapperTest/TheUserType.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Data;
33
using System.Data.Common;
4+
using NHibernate.Engine;
45
using NHibernate.SqlTypes;
56
using NHibernate.UserTypes;
67

@@ -28,14 +29,14 @@ public int GetHashCode(object x)
2829
return x.GetHashCode();
2930
}
3031

31-
public object NullSafeGet(DbDataReader rs, string[] names, object owner)
32+
public object NullSafeGet(DbDataReader rs, string[] names, ISessionImplementor session, object owner)
3233
{
3334
return rs.GetValue(rs.GetOrdinal(names[0]));
3435
}
3536

36-
public void NullSafeSet(DbCommand cmd, object value, int index)
37+
public void NullSafeSet(DbCommand cmd, object value, int index, ISessionImplementor session)
3738
{
38-
NHibernateUtil.String.NullSafeSet(cmd, value, index);
39+
NHibernateUtil.String.NullSafeSet(cmd, value, index, session);
3940
}
4041

4142
public object DeepCopy(object value)

src/NHibernate.Test/NHSpecificTest/EntityWithUserTypeCanHaveLinqGenerators/DoubleStringUserType.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Data;
33
using System.Data.Common;
4+
using NHibernate.Engine;
45
using NHibernate.SqlTypes;
56
using NHibernate.UserTypes;
67

@@ -32,17 +33,17 @@ public int GetHashCode(object x)
3233
return x.GetHashCode();
3334
}
3435

35-
public object NullSafeGet(DbDataReader rs, string[] names, object owner)
36+
public object NullSafeGet(DbDataReader rs, string[] names, ISessionImplementor session, object owner)
3637
{
37-
object obj = NHibernateUtil.String.NullSafeGet(rs, names[0]);
38+
object obj = NHibernateUtil.String.NullSafeGet(rs, names[0], session);
3839
if (obj == null)
3940
{
4041
return null;
4142
}
4243
return Convert.ToDouble((string)obj);
4344
}
4445

45-
public void NullSafeSet(DbCommand cmd, object value, int index)
46+
public void NullSafeSet(DbCommand cmd, object value, int index, ISessionImplementor session)
4647
{
4748
if (value == null)
4849
{

src/NHibernate.Test/NHSpecificTest/EntityWithUserTypeCanHaveLinqGenerators/ExampleUserType.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Data;
33
using System.Data.Common;
4+
using NHibernate.Engine;
45
using NHibernate.SqlTypes;
56
using NHibernate.UserTypes;
67

@@ -58,7 +59,7 @@ public object Disassemble(object value)
5859
public System.Type ReturnedType { get { return typeof(IExample); } }
5960
public bool IsMutable { get { return true; } }
6061

61-
public void NullSafeSet(DbCommand cmd, object value, int index)
62+
public void NullSafeSet(DbCommand cmd, object value, int index, ISessionImplementor session)
6263
{
6364
var dataParameter = cmd.Parameters[index];
6465
var example = (IExample)value;
@@ -73,7 +74,7 @@ public void NullSafeSet(DbCommand cmd, object value, int index)
7374
}
7475
}
7576

76-
public object NullSafeGet(DbDataReader rs, string[] names, object owner)
77+
public object NullSafeGet(DbDataReader rs, string[] names, ISessionImplementor session, object owner)
7778
{
7879
var index = rs.GetOrdinal(names[0]);
7980
if (rs.IsDBNull(index))

src/NHibernate.Test/NHSpecificTest/NH1355/UserTypeTimestamp.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ public bool IsMutable
4949
get { return false; }
5050
}
5151

52-
public object NullSafeGet(DbDataReader rs, string[] names, object owner)
52+
public object NullSafeGet(DbDataReader rs, string[] names, ISessionImplementor session, object owner)
5353
{
5454
return rs.GetValue(rs.GetOrdinal(names[0]));
5555
}
5656

57-
public void NullSafeSet(DbCommand cmd, object value, int index)
57+
public void NullSafeSet(DbCommand cmd, object value, int index, ISessionImplementor session)
5858
{
59-
NHibernateUtil.Binary.NullSafeSet(cmd, value, index);
59+
NHibernateUtil.Binary.NullSafeSet(cmd, value, index, session);
6060
}
6161

6262
public object Replace(object original, object target, object owner)

src/NHibernate.Test/NHSpecificTest/NH1907/MyType.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Data.Common;
3+
using NHibernate.Engine;
34
using NHibernate.SqlTypes;
45
using NHibernate.UserTypes;
56

@@ -61,7 +62,7 @@ public object DeepCopy(object value)
6162
return value;
6263
}
6364

64-
public void NullSafeSet(DbCommand cmd, object value, int index)
65+
public void NullSafeSet(DbCommand cmd, object value, int index, ISessionImplementor session)
6566
{
6667
if (value == null)
6768
{
@@ -78,7 +79,7 @@ public System.Type ReturnedType
7879
get { return typeof(Int32); }
7980
}
8081

81-
public object NullSafeGet(DbDataReader rs, string[] names, object owner)
82+
public object NullSafeGet(DbDataReader rs, string[] names, ISessionImplementor session, object owner)
8283
{
8384
int index0 = rs.GetOrdinal(names[0]);
8485
if (rs.IsDBNull(index0))

0 commit comments

Comments
 (0)