Skip to content

Commit 6b34fc9

Browse files
David EllingsworthDavid Ellingsworth
authored andcommitted
Implement isDirty for OneToOneType and always check if it is dirty or not.
1 parent e263847 commit 6b34fc9

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

src/NHibernate/Type/OneToOneType.cs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,31 @@ public override bool IsOneToOne
5959

6060
public override bool IsDirty(object old, object current, ISessionImplementor session)
6161
{
62-
return false;
62+
if (IsSame(old, current))
63+
{
64+
return false;
65+
}
66+
67+
if (old == null || current == null)
68+
{
69+
return true;
70+
}
71+
72+
if (ForeignKeys.IsTransientFast(GetAssociatedEntityName(), current, session).GetValueOrDefault())
73+
{
74+
return true;
75+
}
76+
77+
object oldId = GetIdentifier(old, session);
78+
object newId = GetIdentifier(current, session);
79+
IType identifierType = GetIdentifierType(session);
80+
81+
return identifierType.IsDirty(oldId, newId, session);
6382
}
6483

6584
public override bool IsDirty(object old, object current, bool[] checkable, ISessionImplementor session)
6685
{
67-
return false;
86+
return this.IsDirty(old, current, session);
6887
}
6988

7089
public override bool IsModified(object old, object current, bool[] checkable, ISessionImplementor session)
@@ -170,7 +189,7 @@ public override object Assemble(object cached, ISessionImplementor session, obje
170189
/// </summary>
171190
public override bool IsAlwaysDirtyChecked
172191
{
173-
get { return false; } //TODO: this is kinda inconsistent with CollectionType
192+
get { return true; } //TODO: this is kinda inconsistent with CollectionType
174193
}
175194

176195
public override string PropertyName

0 commit comments

Comments
 (0)