@@ -42,6 +42,7 @@ protected override HbmMapping GetMappings()
42
42
{
43
43
m . Access ( Accessor . Field ) ;
44
44
m . Key ( k => k . Column ( "EntityId" ) ) ;
45
+ m . Cascade ( Mapping . ByCode . Cascade . All ) ;
45
46
} ,
46
47
r => r . OneToMany ( ) ) ;
47
48
@@ -72,19 +73,12 @@ protected override void OnSetUp()
72
73
{
73
74
using var session = OpenSession ( ) ;
74
75
using var transaction = session . BeginTransaction ( ) ;
75
-
76
- session . CreateSQLQuery (
77
- "INSERT INTO Entity (Id) VALUES (0)"
78
- ) . ExecuteUpdate ( ) ;
79
76
80
- session . CreateSQLQuery (
81
- "INSERT INTO ChildEntity (Id, EntityId) VALUES (0, 0)"
82
- ) . ExecuteUpdate ( ) ;
77
+ var entity = new Entity { Id = EntityId . Id1 } ;
78
+ entity . Children . Add ( new ChildEntity { Id = 0 } ) ;
79
+ entity . Children . Add ( new ChildEntity { Id = 1 } ) ;
80
+ session . Save ( entity ) ;
83
81
84
- session . CreateSQLQuery (
85
- "INSERT INTO ChildEntity (Id, EntityId) VALUES (1, 0)"
86
- ) . ExecuteUpdate ( ) ;
87
-
88
82
transaction . Commit ( ) ;
89
83
}
90
84
@@ -93,8 +87,8 @@ protected override void OnTearDown()
93
87
using var session = OpenSession ( ) ;
94
88
using var transaction = session . BeginTransaction ( ) ;
95
89
96
- session . CreateSQLQuery ( "DELETE FROM ChildEntity") . ExecuteUpdate ( ) ;
97
- session . CreateSQLQuery ( "DELETE FROM Entity ") . ExecuteUpdate ( ) ;
90
+ session . CreateQuery ( "delete from ChildEntity") . ExecuteUpdate ( ) ;
91
+ session . CreateQuery ( "delete from System.Object ") . ExecuteUpdate ( ) ;
98
92
99
93
transaction . Commit ( ) ;
100
94
}
@@ -118,10 +112,10 @@ public async Task LoadsEntityWithEnumIdAndChildrenUsingQueryCacheAsync()
118
112
using var session = OpenSession ( ) ;
119
113
using var transaction = session . BeginTransaction ( ) ;
120
114
var entity = ( await ( session
121
- . Query < Entity > ( )
122
- . FetchMany ( x => x . Children )
123
- . WithOptions ( opt => opt . SetCacheable ( true ) )
124
- . ToListAsync ( cancellationToken ) ) ) [ 0 ] ;
115
+ . Query < Entity > ( )
116
+ . FetchMany ( x => x . Children )
117
+ . WithOptions ( opt => opt . SetCacheable ( true ) )
118
+ . ToListAsync ( cancellationToken ) ) ) [ 0 ] ;
125
119
126
120
await ( transaction . CommitAsync ( cancellationToken ) ) ;
127
121
return entity ;
0 commit comments