File tree Expand file tree Collapse file tree 5 files changed +89
-1
lines changed Expand file tree Collapse file tree 5 files changed +89
-1
lines changed Original file line number Diff line number Diff line change
1
+ using System ;
2
+
3
+ namespace NHibernate . Test . NHSpecificTest . NH3985
4
+ {
5
+ public partial class Process
6
+ {
7
+ #region Extensibility Method Definitions
8
+
9
+ public override bool Equals ( object obj )
10
+ {
11
+ Process toCompare = obj as Process ;
12
+ if ( toCompare == null )
13
+ {
14
+ return false ;
15
+ }
16
+
17
+ if ( Object . Equals ( this . ProcessID , default ( long ) ) &&
18
+ Object . Equals ( toCompare . ProcessID , default ( long ) ) )
19
+ return ReferenceEquals ( this , toCompare ) ;
20
+
21
+ if ( ! Object . Equals ( this . ProcessID , toCompare . ProcessID ) )
22
+ return false ;
23
+
24
+ return true ;
25
+ }
26
+
27
+ public override int GetHashCode ( )
28
+ {
29
+ int hashCode = 13 ;
30
+
31
+ // on transient objects, use the basic GetHashCode()
32
+ if ( Object . Equals ( this . ProcessID , default ( long ) ) )
33
+ return base . GetHashCode ( ) ;
34
+
35
+ hashCode = ( hashCode * 7 ) + ProcessID . GetHashCode ( ) ;
36
+ return hashCode ;
37
+ }
38
+
39
+ #endregion
40
+
41
+ public virtual Guid ProcessID { get ; set ; }
42
+
43
+ public virtual string Name { get ; set ; }
44
+ }
45
+ }
Original file line number Diff line number Diff line change
1
+ using NUnit . Framework ;
2
+ using System ;
3
+
4
+ namespace NHibernate . Test . NHSpecificTest . NH3985
5
+ {
6
+ /// <summary>
7
+ /// The test verifies that subsequent child sessions are not issued in already-disposed state.
8
+ /// </summary>
9
+ [ TestFixture ]
10
+ public class Fixture : BugTestCase
11
+ {
12
+ [ Test ]
13
+ public void GetChildSession_ShouldReturnNonDisposedInstance ( )
14
+ {
15
+ using ( var rootSession = OpenSession ( ) )
16
+ {
17
+ using ( var childSession1 = rootSession . GetChildSession ( ) )
18
+ {
19
+ }
20
+
21
+ using ( var childSession2 = rootSession . GetChildSession ( ) )
22
+ {
23
+ Assert . DoesNotThrow ( new TestDelegate ( ( ) => { childSession2 . Get < Process > ( Guid . NewGuid ( ) ) ; } ) ) ;
24
+ }
25
+ }
26
+ }
27
+ }
28
+ }
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.NH3985" >
3
+ <class name =" Process" >
4
+ <id name =" ProcessID" generator =" guid.comb" />
5
+ <property name =" Name" />
6
+ </class >
7
+ </hibernate-mapping >
Original file line number Diff line number Diff line change 741
741
<Compile Include =" NHSpecificTest\EntityWithUserTypeCanHaveLinqGenerators\FooExample.cs" />
742
742
<Compile Include =" NHSpecificTest\EntityWithUserTypeCanHaveLinqGenerators\IExample.cs" />
743
743
<Compile Include =" Insertordering\NH3931Entities.cs" />
744
+ <Compile Include =" NHSpecificTest\NH3985\Entity.cs" />
745
+ <Compile Include =" NHSpecificTest\NH3985\Fixture.cs" />
744
746
<Compile Include =" NHSpecificTest\NH3247\Entity.cs" />
745
747
<Compile Include =" NHSpecificTest\NH3247\Fixture.cs" />
746
748
<Compile Include =" NHSpecificTest\NH3386\Entity.cs" />
3248
3250
<EmbeddedResource Include =" NHSpecificTest\NH1291AnonExample\Mappings.hbm.xml" />
3249
3251
</ItemGroup >
3250
3252
<ItemGroup >
3253
+ <EmbeddedResource Include =" NHSpecificTest\NH3985\Mappings.hbm.xml" >
3254
+ <SubType >Designer</SubType >
3255
+ </EmbeddedResource >
3251
3256
<EmbeddedResource Include =" Insertordering\FamilyModel\Mappings.hbm.xml" />
3252
3257
<EmbeddedResource Include =" Insertordering\AnimalModel\Mappings.hbm.xml" />
3253
3258
<EmbeddedResource Include =" NHSpecificTest\NH3247\Mappings.hbm.xml" />
Original file line number Diff line number Diff line change @@ -2221,7 +2221,10 @@ public ISession GetChildSession()
2221
2221
2222
2222
CheckAndUpdateSessionStatus ( ) ;
2223
2223
2224
- if ( _childSession == null )
2224
+ var childImpl = _childSession as SessionImpl ;
2225
+
2226
+ // if child session never existed or has already been disposed, create new
2227
+ if ( childImpl == null || childImpl . IsAlreadyDisposed )
2225
2228
{
2226
2229
log . Debug ( "Creating child session." ) ;
2227
2230
_childSession = new SessionImpl ( this ) ;
You can’t perform that action at this time.
0 commit comments