Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
See gh-188
  • Loading branch information
sdeleuze authored and wilkinsona committed Sep 21, 2023
1 parent 56263e7 commit 094d380
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Expand Up @@ -15,6 +15,9 @@ public interface AuthorRepository extends ListCrudRepository<Author, Long> {
@Query("SELECT a FROM Author a WHERE a.name = :name")
Optional<Author> queryFindByName(String name);

@Query(value = "SELECT * FROM author WHERE name = :name", nativeQuery = true)
Optional<Author> nativeQueryFindByName(String name);

Stream<Author> findByNameContaining(String name);

}
Expand Up @@ -52,7 +52,7 @@ private void deleteAll() {

private void queryFindByName() {
Author author1 = this.authorRepository.queryFindByName("Josh Long").orElse(null);
Author author2 = this.authorRepository.queryFindByName("Martin Kleppmann").orElse(null);
Author author2 = this.authorRepository.nativeQueryFindByName("Martin Kleppmann").orElse(null);

System.out.printf("queryFindByName(): author1 = %s%n", author1);
System.out.printf("queryFindByName(): author2 = %s%n", author2);
Expand Down

0 comments on commit 094d380

Please sign in to comment.