File tree Expand file tree Collapse file tree 4 files changed +105
-0
lines changed
Src/NHibernate.Envers.Tests
NetSpecific/Integration/RevisionOnCollectionChange Expand file tree Collapse file tree 4 files changed +105
-0
lines changed Original file line number Diff line number Diff line change 149
149
<Compile Include =" NetSpecific\Integration\RevInfo\Time\LongTest.cs" />
150
150
<Compile Include =" NetSpecific\Integration\ModifiedFlags\Casee.cs" />
151
151
<Compile Include =" NetSpecific\Integration\ModifiedFlags\MergeColModTest.cs" />
152
+ <Compile Include =" NetSpecific\Integration\RevisionOnCollectionChange\Domain.cs" />
153
+ <Compile Include =" NetSpecific\Integration\RevisionOnCollectionChange\Fixture.cs" />
152
154
<Compile Include =" NetSpecific\UnitTests\CustomLists\CustomListClasses.cs" />
153
155
<Compile Include =" NetSpecific\UnitTests\CustomLists\CustomListsTestModel.cs" />
154
156
<Compile Include =" NetSpecific\UnitTests\CustomLists\CustomListTests.cs" />
802
804
<Compile Include =" ValidityTestBase.cs" />
803
805
</ItemGroup >
804
806
<ItemGroup >
807
+ <EmbeddedResource Include =" NetSpecific\Integration\RevisionOnCollectionChange\Mapping.hbm.xml" />
805
808
<EmbeddedResource Include =" NetSpecific\Integration\MultiLevelInheritance\Mapping.hbm.xml" />
806
809
<EmbeddedResource Include =" NetSpecific\Integration\BidirectionalSameColumn\Mapping.hbm.xml" />
807
810
<EmbeddedResource Include =" NetSpecific\Integration\CustomMapping\ImplicitEnversCollectionType\Mapping.hbm.xml" />
Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Collections . Generic ;
3
+ using NHibernate . Envers . Configuration . Attributes ;
4
+
5
+ namespace NHibernate . Envers . Tests . NetSpecific . Integration . RevisionOnCollectionChange
6
+ {
7
+ [ Audited ]
8
+ public class Person
9
+ {
10
+ public Person ( )
11
+ {
12
+ Cars = new List < Car > ( ) ;
13
+ }
14
+ public virtual Guid Id { get ; set ; }
15
+
16
+ public virtual IList < Car > Cars { get ; protected set ; }
17
+ }
18
+
19
+ [ Audited ]
20
+ public class Car
21
+ {
22
+ public virtual Guid Id { get ; set ; }
23
+
24
+ public virtual Person Owner { get ; set ; }
25
+ }
26
+ }
Original file line number Diff line number Diff line change
1
+ using NHibernate . Cfg ;
2
+ using NHibernate . Envers . Configuration ;
3
+ using NUnit . Framework ;
4
+
5
+ namespace NHibernate . Envers . Tests . NetSpecific . Integration . RevisionOnCollectionChange
6
+ {
7
+ [ TestFixture ]
8
+ public class Fixture : TestBase
9
+ {
10
+ private object _newOwnerId ;
11
+ private object _carId ;
12
+
13
+ public Fixture ( string strategyType ) : base ( strategyType )
14
+ {
15
+ }
16
+
17
+ protected override void AddToConfiguration ( Cfg . Configuration configuration )
18
+ {
19
+ configuration . SetEnversProperty ( ConfigurationKey . GlobalWithModifiedFlag , true ) ;
20
+ configuration . SetEnversProperty ( ConfigurationKey . RevisionOnCollectionChange , true ) ;
21
+ base . AddToConfiguration ( configuration ) ;
22
+ }
23
+
24
+ protected override void Initialize ( )
25
+ {
26
+ using ( var tx = Session . BeginTransaction ( ) )
27
+ {
28
+ var oldOwner = new Person ( ) ;
29
+ Session . Save ( oldOwner ) ;
30
+ var newOwner = new Person ( ) ;
31
+ _newOwnerId = Session . Save ( newOwner ) ;
32
+ var car = new Car { Owner = oldOwner } ;
33
+ _carId = Session . Save ( car ) ;
34
+ tx . Commit ( ) ;
35
+ }
36
+ }
37
+
38
+ [ Test ]
39
+ public void ChangeParentReferenceShouldNotThwrowException ( )
40
+ {
41
+ using ( var tx = Session . BeginTransaction ( ) )
42
+ {
43
+ var car = Session . Get < Car > ( _carId ) ;
44
+ car . Owner = Session . Get < Person > ( _newOwnerId ) ;
45
+ tx . Commit ( ) ;
46
+ }
47
+ }
48
+ }
49
+ }
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" utf-8" ?>
2
+ <hibernate-mapping xmlns =" urn:nhibernate-mapping-2.2"
3
+ assembly =" NHibernate.Envers.Tests"
4
+ namespace =" NHibernate.Envers.Tests.NetSpecific.Integration.RevisionOnCollectionChange" >
5
+ <class name =" Car" >
6
+ <id name =" Id" >
7
+ <column name =" Id" />
8
+ <generator class =" guid.comb" />
9
+ </id >
10
+ <many-to-one class =" Person" name =" Owner" >
11
+ <column name =" Owner_Id" />
12
+ </many-to-one >
13
+ </class >
14
+
15
+ <class name =" Person" >
16
+ <id name =" Id" >
17
+ <column name =" Id" />
18
+ <generator class =" guid.comb" />
19
+ </id >
20
+ <bag name =" Cars" >
21
+ <key >
22
+ <column name =" Owner_Id" />
23
+ </key >
24
+ <one-to-many class =" Car" />
25
+ </bag >
26
+ </class >
27
+ </hibernate-mapping >
You can’t perform that action at this time.
0 commit comments