@@ -342,6 +342,42 @@ void findAllPagedAndSorted() {
342
342
"LIMIT 10" );
343
343
}
344
344
345
+ @ Test // GH-1919
346
+ void selectByQuery () {
347
+
348
+ Query query = Query .query (Criteria .where ("id" ).is (23L ));
349
+
350
+ String sql = sqlGenerator .selectByQuery (query , new MapSqlParameterSource ());
351
+
352
+ assertThat (sql ).contains ( //
353
+ "SELECT" , //
354
+ "FROM dummy_entity" , //
355
+ "LEFT OUTER JOIN referenced_entity ref ON ref.dummy_entity = dummy_entity.id1" , //
356
+ "LEFT OUTER JOIN second_level_referenced_entity ref_further ON ref_further.referenced_entity = ref.x_l1id" , //
357
+ "WHERE dummy_entity.id1 = :id1" //
358
+ );
359
+ }
360
+
361
+ @ Test // GH-1919
362
+ void selectBySortedQuery () {
363
+
364
+ Query query = Query .query (Criteria .where ("id" ).is (23L )) //
365
+ .sort (Sort .by (Sort .Order .asc ("id" )));
366
+
367
+ String sql = sqlGenerator .selectByQuery (query , new MapSqlParameterSource ());
368
+
369
+ assertThat (sql ).contains ( //
370
+ "SELECT" , //
371
+ "FROM dummy_entity" , //
372
+ "LEFT OUTER JOIN referenced_entity ref ON ref.dummy_entity = dummy_entity.id1" , //
373
+ "LEFT OUTER JOIN second_level_referenced_entity ref_further ON ref_further.referenced_entity = ref.x_l1id" , //
374
+ "WHERE dummy_entity.id1 = :id1" , //
375
+ "ORDER BY dummy_entity.id1 ASC" //
376
+ );
377
+ assertThat (sql ).containsOnlyOnce ("LEFT OUTER JOIN referenced_entity ref ON ref.dummy_entity = dummy_entity.id1" );
378
+ assertThat (sql ).containsOnlyOnce ("LEFT OUTER JOIN second_level_referenced_entity ref_further ON ref_further.referenced_entity = ref.x_l1id" );
379
+ }
380
+
345
381
@ Test // DATAJDBC-131, DATAJDBC-111
346
382
void findAllByProperty () {
347
383
0 commit comments