From the course: Building Full-Stack Apps with React and Spring

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

JPA repository

JPA repository

- [Instructor] So now we need to create a repository for a new model. With the repository file, we're connecting the model and its primary key into Spring's CRUD. So I get in the same folder called model, we'll create a brand new file. So let's go ahead and create a new file and we're going to call this file ContactRepository.java. And in this file, we'll also use the package. So if you want to go back to Contact, you can literally copy this line here. So we're going to use that, copy that and paste it here. And then we'll import org.springframework dot data.repository dot CrudRepository. So it should be an import though, so let's go and make sure we import this. So org.springframework.data.repository.CrudRepository with a capital R. Once you have that, you should be able to create the repository. So let's go ahead and do public interface ContactRepository extends CrudRepository and then we're going to…

Contents