@@ -37,11 +37,6 @@ protected override string[] Mappings
37
37
get { return new string [ ] { "CompositeId.ClassWithCompositeId.hbm.xml" } ; }
38
38
}
39
39
40
- protected override bool AppliesTo ( Dialect . Dialect dialect )
41
- {
42
- return ! ( dialect is Dialect . FirebirdDialect ) ; // Firebird has no CommandTimeout, and locks up during the tear-down of this fixture
43
- }
44
-
45
40
protected override void OnSetUp ( )
46
41
{
47
42
id = new Id ( "stringKey" , 3 , firstDateTime ) ;
@@ -51,9 +46,11 @@ protected override void OnSetUp()
51
46
protected override void OnTearDown ( )
52
47
{
53
48
using ( ISession s = Sfi . OpenSession ( ) )
49
+ using ( var t = s . BeginTransaction ( ) )
54
50
{
55
51
s . Delete ( "from ClassWithCompositeId" ) ;
56
52
s . Flush ( ) ;
53
+ t . Commit ( ) ;
57
54
}
58
55
}
59
56
@@ -239,5 +236,132 @@ public async Task HqlAsync()
239
236
Assert . AreEqual ( 1 , results . Count ) ;
240
237
}
241
238
}
239
+
240
+ [ Test ]
241
+ public async Task QueryOverInClauseAsync ( )
242
+ {
243
+ if ( ! Dialect . SupportsRowValueConstructorSyntaxInInList )
244
+ Assert . Ignore ( ) ;
245
+
246
+ // insert the new objects
247
+ using ( ISession s = OpenSession ( ) )
248
+ using ( ITransaction t = s . BeginTransaction ( ) )
249
+ {
250
+ await ( s . SaveAsync ( new ClassWithCompositeId ( id ) { OneProperty = 5 } ) ) ;
251
+ await ( s . SaveAsync ( new ClassWithCompositeId ( secondId ) { OneProperty = 10 } ) ) ;
252
+ await ( s . SaveAsync ( new ClassWithCompositeId ( new Id ( id . KeyString , id . GetKeyShort ( ) , secondId . KeyDateTime ) ) ) ) ;
253
+
254
+ await ( t . CommitAsync ( ) ) ;
255
+ }
256
+
257
+ using ( var s = OpenSession ( ) )
258
+ {
259
+ var results = await ( s . QueryOver < ClassWithCompositeId > ( ) . WhereRestrictionOn ( p => p . Id ) . IsIn ( new [ ] { id , secondId } ) . ListAsync ( ) ) ;
260
+ Assert . That ( results . Count , Is . EqualTo ( 2 ) ) ;
261
+ }
262
+ }
263
+
264
+ [ Test ]
265
+ public async Task HqlInClauseAsync ( )
266
+ {
267
+ if ( ! Dialect . SupportsRowValueConstructorSyntaxInInList )
268
+ Assert . Ignore ( ) ;
269
+
270
+ // insert the new objects
271
+ using ( ISession s = OpenSession ( ) )
272
+ using ( ITransaction t = s . BeginTransaction ( ) )
273
+ {
274
+ await ( s . SaveAsync ( new ClassWithCompositeId ( id ) { OneProperty = 5 } ) ) ;
275
+ await ( s . SaveAsync ( new ClassWithCompositeId ( secondId ) { OneProperty = 10 } ) ) ;
276
+ await ( s . SaveAsync ( new ClassWithCompositeId ( new Id ( id . KeyString , id . GetKeyShort ( ) , secondId . KeyDateTime ) ) ) ) ;
277
+
278
+ await ( t . CommitAsync ( ) ) ;
279
+ }
280
+
281
+ using ( var s = OpenSession ( ) )
282
+ {
283
+ var results = await ( s . CreateQuery ( "from ClassWithCompositeId x where x.Id in (:id1, :id2)" )
284
+ . SetParameter ( "id1" , id )
285
+ . SetParameter ( "id2" , secondId )
286
+ . ListAsync < ClassWithCompositeId > ( ) ) ;
287
+ Assert . That ( results . Count , Is . EqualTo ( 2 ) ) ;
288
+ }
289
+ }
290
+
291
+ [ Test ]
292
+ public async Task QueryOverInClauseSubqueryAsync ( )
293
+ {
294
+ if ( ! TestDialect . SupportsRowValueConstructorSyntax )
295
+ {
296
+ Assert . Ignore ( ) ;
297
+ }
298
+
299
+ // insert the new objects
300
+ using ( ISession s = OpenSession ( ) )
301
+ using ( ITransaction t = s . BeginTransaction ( ) )
302
+ {
303
+ await ( s . SaveAsync ( new ClassWithCompositeId ( id ) { OneProperty = 5 } ) ) ;
304
+ await ( s . SaveAsync ( new ClassWithCompositeId ( secondId ) { OneProperty = 10 } ) ) ;
305
+ await ( s . SaveAsync ( new ClassWithCompositeId ( new Id ( id . KeyString , id . GetKeyShort ( ) , secondId . KeyDateTime ) ) ) ) ;
306
+
307
+ await ( t . CommitAsync ( ) ) ;
308
+ }
309
+
310
+ using ( var s = OpenSession ( ) )
311
+ {
312
+ var results = await ( s . QueryOver < ClassWithCompositeId > ( ) . WithSubquery . WhereProperty ( p => p . Id ) . In ( QueryOver . Of < ClassWithCompositeId > ( ) . Where ( p => p . Id . KeyString == id . KeyString ) . Select ( p => p . Id ) ) . ListAsync ( ) ) ;
313
+ Assert . That ( results . Count , Is . EqualTo ( 2 ) ) ;
314
+ }
315
+ }
316
+
317
+ [ Test ]
318
+ public async Task HqlInClauseSubqueryAsync ( )
319
+ {
320
+ if ( ! TestDialect . SupportsRowValueConstructorSyntax )
321
+ Assert . Ignore ( ) ;
322
+
323
+ // insert the new objects
324
+ using ( ISession s = OpenSession ( ) )
325
+ using ( ITransaction t = s . BeginTransaction ( ) )
326
+ {
327
+ await ( s . SaveAsync ( new ClassWithCompositeId ( id ) { OneProperty = 5 } ) ) ;
328
+ await ( s . SaveAsync ( new ClassWithCompositeId ( secondId ) { OneProperty = 10 } ) ) ;
329
+ await ( s . SaveAsync ( new ClassWithCompositeId ( new Id ( id . KeyString , id . GetKeyShort ( ) , secondId . KeyDateTime ) ) ) ) ;
330
+
331
+ await ( t . CommitAsync ( ) ) ;
332
+ }
333
+
334
+ using ( var s = OpenSession ( ) )
335
+ {
336
+ var results = await ( s . CreateQuery ( "from ClassWithCompositeId x where x.Id in (select s.Id from ClassWithCompositeId s where s.Id.KeyString = :keyString)" )
337
+ . SetParameter ( "keyString" , id . KeyString ) . ListAsync ( ) ) ;
338
+ Assert . That ( results . Count , Is . EqualTo ( 2 ) ) ;
339
+ }
340
+ }
341
+
342
+ [ Test ]
343
+ public async Task HqlInClauseSubquery_ForEntityAsync ( )
344
+ {
345
+ if ( ! TestDialect . SupportsRowValueConstructorSyntax )
346
+ Assert . Ignore ( ) ;
347
+
348
+ // insert the new objects
349
+ using ( ISession s = OpenSession ( ) )
350
+ using ( ITransaction t = s . BeginTransaction ( ) )
351
+ {
352
+ await ( s . SaveAsync ( new ClassWithCompositeId ( id ) { OneProperty = 5 } ) ) ;
353
+ await ( s . SaveAsync ( new ClassWithCompositeId ( secondId ) { OneProperty = 10 } ) ) ;
354
+ await ( s . SaveAsync ( new ClassWithCompositeId ( new Id ( id . KeyString , id . GetKeyShort ( ) , secondId . KeyDateTime ) ) ) ) ;
355
+
356
+ await ( t . CommitAsync ( ) ) ;
357
+ }
358
+
359
+ using ( var s = OpenSession ( ) )
360
+ {
361
+ var results = await ( s . CreateQuery ( "from ClassWithCompositeId x where x in (select s from ClassWithCompositeId s where s.Id.KeyString = :keyString)" )
362
+ . SetParameter ( "keyString" , id . KeyString ) . ListAsync ( ) ) ;
363
+ Assert . That ( results . Count , Is . EqualTo ( 2 ) ) ;
364
+ }
365
+ }
242
366
}
243
367
}
0 commit comments