Spring Data JPA has is the ability to create repository implementations automatically, at runtime, from a repository interface. We will see how this works by creating a repository to access the User entities. Create a repositories package and include UserRepository.kt in it:
package com.example.messenger.api.repositoriesimport com.example.messenger.api.models.Userimport org.springframework.data.repository.CrudRepositoryinterface UserRepository : CrudRepository<User, Long> { fun findByUsername(username: String): User? fun findByPhoneNumber(phoneNumber: String): User?}
UserRepository extends the CrudRepository interface. The entity type and id type it works with are specified in the generic parameters of CrudRepository ...