File tree Expand file tree Collapse file tree 5 files changed +17
-6
lines changed
NHibernate/Persister/Entity Expand file tree Collapse file tree 5 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,8 @@ public async Task TestGroupsAsync()
101
101
[ TestCase ( false ) ]
102
102
public async Task TestUpdateAsync ( bool fetchBeforeUpdate , CancellationToken cancellationToken = default ( CancellationToken ) )
103
103
{
104
+ Sfi . Statistics . Clear ( ) ;
105
+
104
106
using ( var s = OpenSession ( ) )
105
107
using ( var tx = s . BeginTransaction ( ) )
106
108
{
@@ -115,6 +117,8 @@ public async Task TestGroupsAsync()
115
117
await ( tx . CommitAsync ( cancellationToken ) ) ;
116
118
}
117
119
120
+ Assert . That ( Sfi . Statistics . EntityUpdateCount , Is . EqualTo ( 1 ) ) ;
121
+
118
122
using ( var s = OpenSession ( ) )
119
123
using ( var tx = s . BeginTransaction ( ) )
120
124
{
Original file line number Diff line number Diff line change @@ -36,6 +36,8 @@ protected override string[] Mappings
36
36
get { return new [ ] { "LazyProperty.Mappings.hbm.xml" } ; }
37
37
}
38
38
39
+ protected override string CacheConcurrencyStrategy => null ;
40
+
39
41
protected override DebugSessionFactory BuildSessionFactory ( )
40
42
{
41
43
using ( var logSpy = new LogSpy ( typeof ( EntityMetamodel ) ) )
Original file line number Diff line number Diff line change @@ -90,6 +90,8 @@ public void TestGroups()
90
90
[ TestCase ( false ) ]
91
91
public void TestUpdate ( bool fetchBeforeUpdate )
92
92
{
93
+ Sfi . Statistics . Clear ( ) ;
94
+
93
95
using ( var s = OpenSession ( ) )
94
96
using ( var tx = s . BeginTransaction ( ) )
95
97
{
@@ -104,6 +106,8 @@ public void TestUpdate(bool fetchBeforeUpdate)
104
106
tx . Commit ( ) ;
105
107
}
106
108
109
+ Assert . That ( Sfi . Statistics . EntityUpdateCount , Is . EqualTo ( 1 ) ) ;
110
+
107
111
using ( var s = OpenSession ( ) )
108
112
using ( var tx = s . BeginTransaction ( ) )
109
113
{
Original file line number Diff line number Diff line change @@ -23,6 +23,8 @@ protected override string[] Mappings
23
23
get { return new [ ] { "LazyProperty.Mappings.hbm.xml" } ; }
24
24
}
25
25
26
+ protected override string CacheConcurrencyStrategy => null ;
27
+
26
28
protected override DebugSessionFactory BuildSessionFactory ( )
27
29
{
28
30
using ( var logSpy = new LogSpy ( typeof ( EntityMetamodel ) ) )
Original file line number Diff line number Diff line change @@ -1460,11 +1460,10 @@ private object InitializeLazyPropertiesFromDatastore(
1460
1460
object [ ] snapshot = entry . LoadedState ;
1461
1461
foreach ( var fetchGroupPropertyDescriptor in fetchGroupPropertyDescriptors )
1462
1462
{
1463
- if ( ! uninitializedLazyProperties . Contains ( fetchGroupPropertyDescriptor . Name ) )
1464
- {
1465
- // its already been initialized (e.g. by a write) so we don't want to overwrite
1466
- continue ;
1467
- }
1463
+ // Iterate over all fetched properties even if they are already set
1464
+ // as their state may not be populated yet. InitializeLazyProperty
1465
+ // method will take care of not overriding their property values and
1466
+ // will only update the states, if they have one.
1468
1467
1469
1468
var selectedValue = fetchGroupPropertyDescriptor . Type . NullSafeGet (
1470
1469
rs ,
@@ -1479,7 +1478,7 @@ private object InitializeLazyPropertiesFromDatastore(
1479
1478
snapshot ,
1480
1479
fetchGroupPropertyDescriptor . LazyIndex ,
1481
1480
selectedValue ,
1482
- null
1481
+ uninitializedLazyProperties
1483
1482
) ;
1484
1483
1485
1484
if ( set )
You can’t perform that action at this time.
0 commit comments