File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
HibernateSpringBootLoadMultipleIdsSpecification/src/main/java/com/bookstore Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,9 @@ public static void main(String[] args) {
2323 public ApplicationRunner init () {
2424 return args -> {
2525
26+ System .out .println ("\n Fetching multiple ids (findAllById()):" );
27+ bookstoreService .fetchByMultipleIdsFindAllById ();
28+
2629 System .out .println ("\n Fetching multiple ids (JPQL):" );
2730 bookstoreService .fetchByMultipleIdsJpql ();
2831
Original file line number Diff line number Diff line change @@ -15,16 +15,22 @@ public BookstoreService(BookRepository bookRepository) {
1515 this .bookRepository = bookRepository ;
1616 }
1717
18+ public void fetchByMultipleIdsFindAllById () {
19+
20+ List <Book > books = bookRepository .findAllById (List .of (1L , 2L , 5L ));
21+ System .out .println (books );
22+ }
23+
1824 public void fetchByMultipleIdsJpql () {
19-
25+
2026 List <Book > books = bookRepository .fetchByMultipleIds (List .of (1L , 2L , 5L ));
2127 System .out .println (books );
2228 }
23-
29+
2430 public void fetchByMultipleIdsSpec () {
25-
31+
2632 List <Book > books = bookRepository .findAll (
27- new InIdsSpecification (List .of (1L , 2L , 5L )));
33+ new InIdsSpecification (List .of (1L , 2L , 5L )));
2834 System .out .println (books );
2935 }
3036}
You can’t perform that action at this time.
0 commit comments