The CrudRepository interface

We can extend CrudRepository to expose all create, read, update, and delete methods on an entity. The following snippet shows TodoRepository extending CrudRepository:

    public interface TodoRepository extends CrudRepository<Todo, Long>     {    }

TodoRepository can be used to perform all methods exposed by the CrudRepository interface. Let's write a few unit tests to test some of these methods.

Get Mastering Spring 5.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.