Implementation of Spring Data JPA repositories

With the domain model implemented successfully, JpaRepository for those can be implemented using Spring Data JPA. The specialty here is that there is no need to implement anything. Just writing an interface that extends from the JpaRepository interface will be sufficient to expose methods to find one, find all, save, delete, and so on. The following code shows UserRepository:

public interface UserRepository extends JpaRepository<User, Integer> {

User findByEmail(String email);

User findByUsername(String username);

}

In the preceding code, there are methods named findByUsername and findByEmail where username and email are properties of the User class.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.227.183.153