File tree Expand file tree Collapse file tree 5 files changed +188
-0
lines changed Expand file tree Collapse file tree 5 files changed +188
-0
lines changed Original file line number Diff line number Diff line change 1+ using System ;
2+ using NUnit . Framework ;
3+ using SharpTestsEx ;
4+
5+ namespace NHibernate . Test . NHSpecificTest . NH3570
6+ {
7+ [ TestFixture ]
8+ public class BiFixture : BugTestCase
9+ {
10+ private Guid id ;
11+
12+ [ Test ]
13+ [ KnownBug ( "NH-3570" ) ]
14+ public void ShouldNotSaveRemoveChild ( )
15+ {
16+ var parent = new BiParent ( ) ;
17+ parent . AddChild ( new BiChild ( ) ) ;
18+ using ( var s = OpenSession ( ) )
19+ {
20+ using ( var tx = s . BeginTransaction ( ) )
21+ {
22+ id = ( Guid ) s . Save ( parent ) ;
23+ parent . Children . Clear ( ) ;
24+ parent . AddChild ( new BiChild ( ) ) ;
25+ tx . Commit ( ) ;
26+ }
27+ }
28+ using ( var s = OpenSession ( ) )
29+ {
30+ using ( s . BeginTransaction ( ) )
31+ {
32+ s . Get < BiParent > ( id ) . Children . Count . Should ( ) . Be . EqualTo ( 1 ) ;
33+ s . CreateCriteria < BiChild > ( ) . List ( ) . Count . Should ( ) . Be . EqualTo ( 1 ) ;
34+ }
35+ }
36+ }
37+
38+ protected override void OnTearDown ( )
39+ {
40+ using ( var s = OpenSession ( ) )
41+ {
42+ using ( var tx = s . BeginTransaction ( ) )
43+ {
44+ s . CreateQuery ( "delete from BiChild" ) . ExecuteUpdate ( ) ;
45+ s . CreateQuery ( "delete from BiParent" ) . ExecuteUpdate ( ) ;
46+ tx . Commit ( ) ;
47+ }
48+ }
49+ }
50+ }
51+ }
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" assembly =" NHibernate.Test" namespace =" NHibernate.Test.NHSpecificTest.NH3570" >
3+ <class name =" UniParent" >
4+ <id name =" Id" >
5+ <generator class =" guid.comb" />
6+ </id >
7+ <version name =" Version" />
8+ <bag name =" Children" cascade =" all-delete-orphan" >
9+ <key column =" parentId" />
10+ <one-to-many class =" UniChild" />
11+ </bag >
12+ </class >
13+ <class name =" UniChild" >
14+ <id name =" Id" >
15+ <generator class =" guid.comb" />
16+ </id >
17+ </class >
18+
19+ <class name =" BiParent" >
20+ <id name =" Id" >
21+ <generator class =" guid.comb" />
22+ </id >
23+ <version name =" Version" />
24+ <bag name =" Children" cascade =" all-delete-orphan" inverse =" true" >
25+ <key column =" parentId" />
26+ <one-to-many class =" BiChild" />
27+ </bag >
28+ </class >
29+ <class name =" BiChild" >
30+ <id name =" Id" >
31+ <generator class =" guid.comb" />
32+ </id >
33+ <many-to-one class =" BiParent" name =" Parent" column =" parentId" />
34+ </class >
35+ </hibernate-mapping >
36+
Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Collections . Generic ;
3+
4+ namespace NHibernate . Test . NHSpecificTest . NH3570
5+ {
6+ public class UniParent
7+ {
8+ public UniParent ( )
9+ {
10+ Children = new List < UniChild > ( ) ;
11+ }
12+
13+ public virtual Guid Id { get ; set ; }
14+ public virtual IList < UniChild > Children { get ; set ; }
15+ public virtual int Version { get ; set ; }
16+ }
17+
18+ public class UniChild
19+ {
20+ public virtual Guid Id { get ; set ; }
21+ }
22+
23+ public class BiParent
24+ {
25+ public BiParent ( )
26+ {
27+ Children = new List < BiChild > ( ) ;
28+ }
29+
30+ public virtual Guid Id { get ; set ; }
31+ public virtual IList < BiChild > Children { get ; set ; }
32+ public virtual int Version { get ; set ; }
33+
34+ public virtual void AddChild ( BiChild child )
35+ {
36+ child . Parent = this ;
37+ Children . Add ( child ) ;
38+ }
39+ }
40+
41+ public class BiChild
42+ {
43+ public virtual Guid Id { get ; set ; }
44+ public virtual BiParent Parent { get ; set ; }
45+ }
46+ }
Original file line number Diff line number Diff line change 1+ using System ;
2+ using NUnit . Framework ;
3+ using SharpTestsEx ;
4+
5+ namespace NHibernate . Test . NHSpecificTest . NH3570
6+ {
7+ [ TestFixture ]
8+ public class UniFixture : BugTestCase
9+ {
10+ private Guid id ;
11+
12+ [ Test ]
13+ [ KnownBug ( "NH-3570" ) ]
14+ public void ShouldNotSaveRemoveChild ( )
15+ {
16+ var parent = new UniParent ( ) ;
17+ parent . Children . Add ( new UniChild ( ) ) ;
18+ using ( var s = OpenSession ( ) )
19+ {
20+ using ( var tx = s . BeginTransaction ( ) )
21+ {
22+ id = ( Guid ) s . Save ( parent ) ;
23+ parent . Children . Clear ( ) ;
24+ parent . Children . Add ( new UniChild ( ) ) ;
25+ tx . Commit ( ) ;
26+ }
27+ }
28+ using ( var s = OpenSession ( ) )
29+ {
30+ using ( s . BeginTransaction ( ) )
31+ {
32+ s . Get < UniParent > ( id ) . Children . Count . Should ( ) . Be . EqualTo ( 1 ) ;
33+ s . CreateCriteria < UniChild > ( ) . List ( ) . Count . Should ( ) . Be . EqualTo ( 1 ) ;
34+ }
35+ }
36+ }
37+
38+ protected override void OnTearDown ( )
39+ {
40+ using ( var s = OpenSession ( ) )
41+ {
42+ using ( var tx = s . BeginTransaction ( ) )
43+ {
44+ s . CreateQuery ( "delete from UniChild" ) . ExecuteUpdate ( ) ;
45+ s . CreateQuery ( "delete from UniParent" ) . ExecuteUpdate ( ) ;
46+ tx . Commit ( ) ;
47+ }
48+ }
49+ }
50+ }
51+ }
Original file line number Diff line number Diff line change 690690 <Compile Include =" NHSpecificTest\BagWithLazyExtraAndFilter\Fixture.cs" />
691691 <Compile Include =" Linq\ByMethod\DistinctTests.cs" />
692692 <Compile Include =" Component\Basic\ComponentWithUniqueConstraintTests.cs" />
693+ <Compile Include =" NHSpecificTest\NH3570\BiFixture.cs" />
694+ <Compile Include =" NHSpecificTest\NH3570\Model.cs" />
695+ <Compile Include =" NHSpecificTest\NH3570\UniFixture.cs" />
693696 <Compile Include =" NHSpecificTest\NH3620\Fixture.cs" />
694697 <Compile Include =" NHSpecificTest\NH3620\TwoBlobs.cs" />
695698 <Compile Include =" NHSpecificTest\NH3455\Address.cs" />
30543057 <EmbeddedResource Include =" NHSpecificTest\NH1291AnonExample\Mappings.hbm.xml" />
30553058 </ItemGroup >
30563059 <ItemGroup >
3060+ <EmbeddedResource Include =" NHSpecificTest\NH3570\Mappings.hbm.xml" />
30573061 <EmbeddedResource Include =" NHSpecificTest\NH3455\Mappings.hbm.xml" />
30583062 <EmbeddedResource Include =" NHSpecificTest\NH3590\Mappings.hbm.xml" />
30593063 <EmbeddedResource Include =" NHSpecificTest\NH3377\Mappings.hbm.xml" />
You can’t perform that action at this time.
0 commit comments