Skip to content

Commit 77dec6f

Browse files
committed
Query By Example (QBE)
1 parent 0d4324d commit 77dec6f

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

HibernateSpringBootExampleApi/src/main/java/com/bookstore/MainApplication.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ public ApplicationRunner init() {
3434
book.setAuthor("Olivia Goy");
3535
book.setPrice(23);
3636

37-
boolean foundAnd = bookstoreService.existsBookAnd(book);
38-
System.out.println("\nFound (and): " + foundAnd);
37+
boolean foundAnd = bookstoreService.existsBook1(book);
38+
System.out.println("Found (existsBook1): " + foundAnd + "\n");
3939

40-
boolean foundOr = bookstoreService.existsBookAnd(book);
41-
System.out.println("\nFound (or): " + foundOr);
40+
boolean foundOr = bookstoreService.existsBook2(book);
41+
System.out.println("Found (existsBook2): " + foundOr + "\n");
4242

43-
boolean foundIgnorePath = bookstoreService.existsBookIgnorePath(book);
44-
System.out.println("\nFound (ignore path): " + foundIgnorePath);
43+
boolean foundIgnorePath = bookstoreService.existsBook3(book);
44+
System.out.println("Found (existsBook3): " + foundIgnorePath + "\n");
4545
};
4646
}
4747
}

HibernateSpringBootExampleApi/src/main/java/com/bookstore/service/BookstoreService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@ public BookstoreService(BookRepository bookRepository) {
1515
this.bookRepository = bookRepository;
1616
}
1717

18-
public boolean existsBookAnd(Book book) {
18+
public boolean existsBook1(Book book) {
1919

2020
Example<Book> bookExample = Example.of(book);
2121
return bookRepository.exists(bookExample);
2222
}
2323

24-
public boolean existsBookOr(Book book) {
24+
public boolean existsBook2(Book book) {
2525

2626
Example<Book> bookExample = Example.of(book,
2727
ExampleMatcher.matchingAll().withIgnorePaths("genre").withIgnorePaths("price"));
2828
return bookRepository.exists(bookExample);
2929
}
3030

31-
public boolean existsBookIgnorePath(Book book) {
31+
public boolean existsBook3(Book book) {
3232

3333
Example<Book> bookExample = Example.of(book,
3434
ExampleMatcher.matchingAny().withIgnorePaths("genre").withIgnorePaths("price"));

0 commit comments

Comments
 (0)