1. Roger Kratz
  2. NHibernate.Envers

Commits

Roger Kratz  committed 0590279

Fixing NHE-131 for not-found="ignore"

  • Participants
  • Parent commits 15036aa
  • Branches default

Comments (0)

Files changed (5)

File Src/NHibernate.Envers.Tests/NHibernate.Envers.Tests.csproj

View file
  • Ignore whitespace
     <Compile Include="NetSpecific\Integration\Component\DerivedComponentTest.cs" />
     <Compile Include="NetSpecific\Integration\NotFoundIgnore\BaseType\Child.cs" />
     <Compile Include="NetSpecific\Integration\NotFoundIgnore\BaseType\ChildName.cs" />
-    <Compile Include="NetSpecific\Integration\NotFoundIgnore\BaseType\NotFoundIgnoreInBaseTypeTest.cs" />
+    <Compile Include="NetSpecific\Integration\NotFoundIgnore\BaseType\NotFoundIgnoreExistsInBaseTypeTest.cs" />
+    <Compile Include="NetSpecific\Integration\NotFoundIgnore\BaseType\NotFoundIgnoreNotExistsInBaseTypeTest.cs" />
     <Compile Include="NetSpecific\Integration\NotFoundIgnore\BaseType\Parent.cs" />
     <Compile Include="NetSpecific\Integration\RevInfo\Time\DateTimeTest.cs" />
     <Compile Include="NetSpecific\Integration\RevInfo\Time\LongTest.cs" />

File Src/NHibernate.Envers.Tests/NetSpecific/Integration/NotFoundIgnore/BaseType/NotFoundIgnoreExistsInBaseTypeTest.cs

View file
  • Ignore whitespace
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using NUnit.Framework;
+using SharpTestsEx;
+
+namespace NHibernate.Envers.Tests.NetSpecific.Integration.NotFoundIgnore.BaseType
+{
+	[TestFixture]
+	public class NotFoundIgnoreExistsInBaseTypeTest : TestBase
+	{
+		private Guid parentId;
+
+		public NotFoundIgnoreExistsInBaseTypeTest(string strategyType) : base(strategyType)
+		{
+		}
+
+		protected override void Initialize()
+		{
+			var childName = new ChildName {Name = "the child"};
+			var parent = new Parent();
+			var boy = new Boy();
+			var girl = new Girl{Name = childName};
+			parent.Children = new List<Child> {boy};
+			using (var tx = Session.BeginTransaction())
+			{
+				Session.Save(childName);
+				parentId = (Guid) Session.Save(parent);
+				tx.Commit();
+			}
+			using (var tx = Session.BeginTransaction())
+			{
+				parent.Children.Add(girl);
+				tx.Commit();
+			}
+		}
+
+		[Test]
+		public void VerifyRevisionCount()
+		{
+			AuditReader().GetRevisions(typeof(Parent), parentId)
+				.Should().Have.SameSequenceAs(1, 2);
+		}
+
+		[Test]
+		public void VerifyHistory()
+		{
+			var ver1children = AuditReader().Find<Parent>(parentId, 1).Children;
+			var ver2children = AuditReader().Find<Parent>(parentId, 2).Children;
+
+			ver1children.Single().Sex.Should().Be.EqualTo("Boy");
+			ver2children[0].Sex.Should().Be.EqualTo("Boy");
+			ver2children[1].Sex.Should().Be.EqualTo("Girl");
+		}
+	}
+}

File Src/NHibernate.Envers.Tests/NetSpecific/Integration/NotFoundIgnore/BaseType/NotFoundIgnoreInBaseTypeTest.cs

  • Ignore whitespace
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using NUnit.Framework;
-using SharpTestsEx;
-
-namespace NHibernate.Envers.Tests.NetSpecific.Integration.NotFoundIgnore.BaseType
-{
-	[TestFixture]
-	public class NotFoundIgnoreInBaseTypeTest : TestBase
-	{
-		private Guid parentId;
-
-		public NotFoundIgnoreInBaseTypeTest(string strategyType) : base(strategyType)
-		{
-		}
-
-		protected override void Initialize()
-		{
-			var childName = new ChildName {Name = "the child"};
-			var parent = new Parent();
-			var boy = new Boy();
-			var girl = new Girl{Name = childName};
-			parent.Children = new List<Child> {boy};
-			using (var tx = Session.BeginTransaction())
-			{
-				Session.Save(childName);
-				parentId = (Guid) Session.Save(parent);
-				tx.Commit();
-			}
-			using (var tx = Session.BeginTransaction())
-			{
-				parent.Children.Add(girl);
-				tx.Commit();
-			}
-		}
-
-		[Test]
-		public void VerifyRevisionCount()
-		{
-			AuditReader().GetRevisions(typeof(Parent), parentId)
-				.Should().Have.SameSequenceAs(1, 2);
-		}
-
-		[Test]
-		public void VerifyHistory()
-		{
-			var ver1children = AuditReader().Find<Parent>(parentId, 1).Children;
-			var ver2children = AuditReader().Find<Parent>(parentId, 2).Children;
-
-			ver1children.Single().Sex.Should().Be.EqualTo("Boy");
-			ver2children[0].Sex.Should().Be.EqualTo("Boy");
-			ver2children[1].Sex.Should().Be.EqualTo("Girl");
-		}
-	}
-}

File Src/NHibernate.Envers.Tests/NetSpecific/Integration/NotFoundIgnore/BaseType/NotFoundIgnoreNotExistsInBaseTypeTest.cs

View file
  • Ignore whitespace
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using NUnit.Framework;
+using SharpTestsEx;
+
+namespace NHibernate.Envers.Tests.NetSpecific.Integration.NotFoundIgnore.BaseType
+{
+	[TestFixture]
+	public class NotFoundIgnoreNotExistsInBaseTypeTest : TestBase
+	{
+		private Guid parentId;
+
+		public NotFoundIgnoreNotExistsInBaseTypeTest(string strategyType) : base(strategyType)
+		{
+		}
+
+		protected override void Initialize()
+		{
+			var childName = new ChildName { Name = "the child" };
+			var parent = new Parent();
+			var girl = new Girl { Name = childName };
+			parent.Children = new List<Child> { girl };
+			using (var tx = Session.BeginTransaction())
+			{
+				Session.Save(childName);
+				parentId = (Guid)Session.Save(parent);
+				tx.Commit();
+			}
+			using (var tx = Session.BeginTransaction())
+			{
+				Session.Delete(childName);
+				tx.Commit();
+			}
+		}
+
+		[Test]
+		public void VerifyRevisionCount()
+		{
+			AuditReader().GetRevisions(typeof(Parent), parentId)
+				.Should().Have.SameSequenceAs(1);
+		}
+
+		[Test]
+		public void VerifyHistory()
+		{
+			AuditReader().Find<Parent>(parentId, 1).Children
+				.Single().Name.Should().Be.Null();
+		}
+	}
+}

File Src/NHibernate.Envers/Entities/Mapper/Relation/ToOneIdMapper.cs

View file
  • Ignore whitespace
 					if (!referencedEntity.IsAudited)
 					{
 						var referencingEntityName = verCfg.EntCfg.GetEntityNameForVersionsEntityName((string) data["$type$"]);
-						//not really correct if property is in base type
-						var relation = verCfg.EntCfg[referencingEntityName].GetRelationDescription(PropertyData.Name);
+						var relation = verCfg.EntCfg.GetRelationDescription(referencingEntityName, PropertyData.Name);
 						ignoreNotFound = relation != null && relation.IsIgnoreNotFound;
-						//
 					}
 					var persister = versionsReader.SessionImplementor.Factory.GetEntityPersister(_referencedEntityName);
 					var removed = RevisionType.Deleted.Equals(data[verCfg.AuditEntCfg.RevisionTypePropName]);