1 // カスタムクエリ試験条件 2 @Test 3。 公共 ボイドtestFindAllByExample(){ 4つの。 // ページングパラメータは、 5。 INTページ= 0; // 0から始まる 6。 int型のサイズ= 10 ; 7 / * 。8つの //ページングパラメータ 9。 IF (ページ<= 0){ 10 。ページ= 1; 11 } 12は、 {IF(<= 0のサイズ) 13である ;サイズ= 10 14 } 15 ページングクエリの//コンストラクタメソッド 16 。ページページ= - 1; 17。 * / 18 ページング可能ページング可能= PageRequest.of(ページ、サイズ); 19 20 // オブジェクトの状態値 21 CmsPage cmsPage = 新新CmsPage(); 22 // クエリ5a751fab6abb5044e0d19ea1サイトのページへ 23 // cmsPage.setSiteId( "5a751fab6abb5044e0d19ea1" ); 24 // 設定テンプレートID条件 25 // cmsPage.setTemplateId( "5ad9a24d68db5239b8fef199"); 26 // セットPageAlias 27 cmsPage.setPageAliase( "カルーセル" ); 28 // 条件マッチャ 29 / *ExampleMatcher exampleMatcher = ExampleMatcher.matching()。 30 exampleMatcher = exampleMatcher.withMatcher( "pageAliase"、ExampleMatcher.GenericPropertyMatchers.contains())。 31 // exampleMatcher = exampleMatcher.withMatcher( "れるtemplateId"、ExampleMatcher.GenericPropertyMatchers.contains())。 32 * / 33 ExampleMatcher exampleMatcher = ExampleMatcher.matching() 34 .withMatcher( "pageAliase" 、ExampleMatcher.GenericPropertyMatchers.contains()) 35 .withMatcher( "れるtemplateId" 、ExampleMatcher.GenericPropertyMatchers.contains())。 36 //ExampleMatcher.GenericPropertyMatchers.contains()キーワード(ファジーマッチ)を含む 37 // ExampleMatcher.GenericPropertyMatchers.startsWith()マッチ接頭辞 で38 // ExampleMatcher.GenericPropertyMatchers.exact()プロセス状態完全一致(デフォルト) 39個の 40 // 定義された条件オブジェクト例 41は 、実施例<cmsPage> =実施例; Example.of(cmsPage、exampleMatcher) 42は ページ<cmsPage>すべて= ; cmsPageRepository.findAll(例えば、ページング可能) 43が リスト<cmsPage> content1 all.getContent =(); // データリスト 44は、 ロング totalElements all.getTotalElements =(); // データ・レコードの総数が 45 46であります リスト<CmsPage>コンテンツ= all.getContent()。 47 のSystem.out.println(コンテンツ)。 48 }
カスタム条件クエリテスト
おすすめ
転載: www.cnblogs.com/foshuo-cv/p/12036795.html
おすすめ
ランキング