@@ -30,6 +30,7 @@ protected override HbmMapping GetMappings()
30
30
{
31
31
m . Access ( Accessor . Field ) ;
32
32
m . Key ( k => k . Column ( "EntityId" ) ) ;
33
+ m . Cascade ( Mapping . ByCode . Cascade . All ) ;
33
34
} ,
34
35
r => r . OneToMany ( ) ) ;
35
36
@@ -60,19 +61,12 @@ protected override void OnSetUp()
60
61
{
61
62
using var session = OpenSession ( ) ;
62
63
using var transaction = session . BeginTransaction ( ) ;
63
-
64
- session . CreateSQLQuery (
65
- "INSERT INTO Entity (Id) VALUES (0)"
66
- ) . ExecuteUpdate ( ) ;
67
64
68
- session . CreateSQLQuery (
69
- "INSERT INTO ChildEntity (Id, EntityId) VALUES (0, 0)"
70
- ) . ExecuteUpdate ( ) ;
65
+ var entity = new Entity { Id = EntityId . Id1 } ;
66
+ entity . Children . Add ( new ChildEntity { Id = 0 } ) ;
67
+ entity . Children . Add ( new ChildEntity { Id = 1 } ) ;
68
+ session . Save ( entity ) ;
71
69
72
- session . CreateSQLQuery (
73
- "INSERT INTO ChildEntity (Id, EntityId) VALUES (1, 0)"
74
- ) . ExecuteUpdate ( ) ;
75
-
76
70
transaction . Commit ( ) ;
77
71
}
78
72
@@ -81,8 +75,8 @@ protected override void OnTearDown()
81
75
using var session = OpenSession ( ) ;
82
76
using var transaction = session . BeginTransaction ( ) ;
83
77
84
- session . CreateSQLQuery ( "DELETE FROM ChildEntity") . ExecuteUpdate ( ) ;
85
- session . CreateSQLQuery ( "DELETE FROM Entity ") . ExecuteUpdate ( ) ;
78
+ session . CreateQuery ( "delete from ChildEntity") . ExecuteUpdate ( ) ;
79
+ session . CreateQuery ( "delete from System.Object ") . ExecuteUpdate ( ) ;
86
80
87
81
transaction . Commit ( ) ;
88
82
}
@@ -106,10 +100,10 @@ private Entity LoadEntityWithQueryCache()
106
100
using var session = OpenSession ( ) ;
107
101
using var transaction = session . BeginTransaction ( ) ;
108
102
var entity = session
109
- . Query < Entity > ( )
110
- . FetchMany ( x => x . Children )
111
- . WithOptions ( opt => opt . SetCacheable ( true ) )
112
- . ToList ( ) [ 0 ] ;
103
+ . Query < Entity > ( )
104
+ . FetchMany ( x => x . Children )
105
+ . WithOptions ( opt => opt . SetCacheable ( true ) )
106
+ . ToList ( ) [ 0 ] ;
113
107
114
108
transaction . Commit ( ) ;
115
109
return entity ;
0 commit comments