Skip to content

Commit c806f87

Browse files
committed
Test for #37 NHibernate.MappingException: No persister for: ProxyForFieldInterceptor
1 parent 0ee2e85 commit c806f87

File tree

4 files changed

+83
-0
lines changed

4 files changed

+83
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using NHibernate.Envers.Configuration.Attributes;
2+
3+
namespace NHibernate.Envers.Tests.Integration.LazyProperty
4+
{
5+
[Audited]
6+
public class Car
7+
{
8+
public virtual long Id { get; set; }
9+
public virtual int Number { get; set; }
10+
public virtual Person Owner { get; set; }
11+
}
12+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using NUnit.Framework;
2+
using System.Linq;
3+
4+
namespace NHibernate.Envers.Tests.Integration.LazyProperty
5+
{
6+
public class LazyPropertyTest : TestBase
7+
{
8+
private long id_pers1;
9+
10+
public LazyPropertyTest(AuditStrategyForTest strategyType) : base(strategyType)
11+
{
12+
}
13+
14+
protected override void Initialize()
15+
{
16+
var pers1 = new Person {Name = "Hernan"};
17+
18+
using (var tx = Session.BeginTransaction())
19+
{
20+
id_pers1 = (long) Session.Save(pers1);
21+
tx.Commit();
22+
}
23+
}
24+
25+
[Test]
26+
public void SavePersonProxyForFieldInterceptor()
27+
{
28+
using (var tx = Session.BeginTransaction())
29+
{
30+
var pers = Session.Query<Person>().Single(x => x.Id == id_pers1);
31+
var car = new Car
32+
{
33+
Owner = pers
34+
};
35+
id_pers1 = (long) Session.Save(car);
36+
tx.Commit();
37+
}
38+
}
39+
}
40+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
2+
assembly="NHibernate.Envers.Tests"
3+
namespace="NHibernate.Envers.Tests.Integration.LazyProperty">
4+
<class name="Person" table="DRIVERS">
5+
<id name="Id" column="ID_PERSON" type="long">
6+
<generator class="native"/>
7+
</id>
8+
<property name="Name" type="string" length="255"
9+
column="NAME" not-null="true" lazy="true"/>
10+
</class>
11+
12+
13+
<class name="Car">
14+
<id name="Id" column="ID_CAR" type="long">
15+
<generator class="native"/>
16+
</id>
17+
<property name="Number" type="int" not-null="true" column="numb"/>
18+
<many-to-one name="Owner" class="Person"/>
19+
</class>
20+
</hibernate-mapping>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using NHibernate.Envers.Configuration.Attributes;
2+
3+
namespace NHibernate.Envers.Tests.Integration.LazyProperty
4+
{
5+
[Audited]
6+
public class Person
7+
{
8+
public virtual long Id { get; set; }
9+
public virtual string Name { get; set; }
10+
}
11+
}

0 commit comments

Comments
 (0)