Skip to content

Commit 3c48bf8

Browse files
committed
Merge pull request #116 from firo222/master
Fix for Issue #110
2 parents dbbdb3f + 2d8bdbf commit 3c48bf8

File tree

3 files changed

+49
-5
lines changed

3 files changed

+49
-5
lines changed

src/FluentNHibernate.Testing/DomainModel/Mapping/CompositeIdentityPartTester.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,26 @@ public void MixedKeyPropertyAndManyToOneOrdering()
159159
.RootElement.Element("class/composite-id/*[2]")
160160
.HasName("key-property");
161161
}
162+
163+
[Test]
164+
public void CompositeIdWithSubclass()
165+
{
166+
new MappingTester<CompIdTarget>()
167+
.SubClassMapping<ComIdSubclass>(s =>
168+
{
169+
s.Table("subclasstable");
170+
s.KeyColumn("subclass_longId");
171+
s.KeyColumn("subclass_nullablelongId");
172+
})
173+
.ForMapping(c => c.CompositeId()
174+
.KeyProperty(x => x.LongId)
175+
.KeyProperty(x => x.NullableLongId))
176+
.Element("class/joined-subclass/key/*[1]")
177+
.Exists().HasName("column").HasAttribute("name", "subclass_longId")
178+
.RootElement.Element("class/joined-subclass/key/*[2]")
179+
.Exists().HasName("column").HasAttribute("name", "subclass_nullablelongId")
180+
;
181+
}
162182

163183
public class CompIdTarget
164184
{
@@ -183,5 +203,10 @@ public class ComponentKey
183203
public virtual int KeyCol1 { get; set; }
184204
public virtual int KeyCol2 { get; set; }
185205
}
206+
207+
public class ComIdSubclass : CompIdTarget
208+
{
209+
210+
}
186211
}
187212
}

src/FluentNHibernate/MappingModel/Collections/AttributeLayeredValues.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4+
using System.Runtime.Serialization;
45

56
namespace FluentNHibernate.MappingModel.Collections
67
{
78
[Serializable]
8-
public class AttributeLayeredValues
9+
public class AttributeLayeredValues : ISerializable
910
{
10-
readonly Dictionary<string, LayeredValues> inner = new Dictionary<string, LayeredValues>();
11+
readonly Dictionary<string, LayeredValues> inner;
1112

13+
public AttributeLayeredValues()
14+
{
15+
inner = new Dictionary<string, LayeredValues>();
16+
}
17+
18+
public AttributeLayeredValues(SerializationInfo info, StreamingContext context)
19+
{
20+
inner = (Dictionary<string, LayeredValues>)info
21+
.GetValue("inner", typeof(Dictionary<string, LayeredValues>));
22+
inner.OnDeserialization(this);
23+
}
24+
1225
public LayeredValues this[string attribute]
1326
{
1427
get
@@ -90,5 +103,10 @@ public override int GetHashCode()
90103

91104
return hashCode;
92105
}
106+
107+
public void GetObjectData(SerializationInfo info, StreamingContext context)
108+
{
109+
info.AddValue("inner", inner);
110+
}
93111
}
94112
}

src/FluentNHibernate/MappingModel/ColumnMapping.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,14 @@ public ColumnMapping Clone()
9494

9595
public bool Equals(ColumnMapping other)
9696
{
97-
return Equals(other.attributes, attributes) && Equals(other.Member, Member);
97+
return (other != null) &&
98+
Equals(other.attributes, attributes) &&
99+
Equals(other.Member, Member);
98100
}
99101

100102
public override bool Equals(object obj)
101103
{
102-
if (obj.GetType() != typeof(ColumnMapping)) return false;
103-
return Equals((ColumnMapping)obj);
104+
return Equals(obj as ColumnMapping);
104105
}
105106

106107
public override int GetHashCode()

0 commit comments

Comments
 (0)