From the course: Spring Data
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Spring Data MongoDB - Spring Tutorial
From the course: Spring Data
Spring Data MongoDB
- [Instructor] Spring Data supports many types of data sources via the commons CRUD repository. We've already seen it in action with Spring Data JPA, let's leverage what we learned and apply it to MongoDB. So I'm going to create a new folder called repo. And guess what? I'm going to create repositories in there. Let's create one for Department. And that is an interface. And let's create one for Staff. And that's also interface. So rather than me having to type everything, I'm just going to copy from branch 06_02e the DepartmentRepo. And then, we'll talk through it. And now, how about the StaffRepo? And let's make sure that the IDE is cleared. So we have a DepartmentRepo, which extends from MongoRepository. And that extends from paging and sorting repository, query by example, executor, and CRUD repository. And we have three query methods, findByName, findByChairId, and they are simple property expressions. findNameByPattern issues adjacent query, which performs a regular expression…