Last active
August 13, 2022 01:38
-
-
Save wohhie/ece090a930d06b46fbf2832448d308b2 to your computer and use it in GitHub Desktop.
Custom findStudentByEmail function will fetch student information
using student email address.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* FIND SOMEONE WITH GIVEN EMAIL ADDRESS | |
* ==========================================================================*/ | |
studentRepository | |
.findStudentByEmail("[email protected]") | |
.ifPresentOrElse( | |
System.out::println, | |
()-> System.out.println("Student with email [email protected] not found")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface StudentRepository extends JpaRepository<Student, Long> { | |
Optional<Student> findStudentByEmail(String email); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment