Define Task Repository
An entity isn't much use by itself, so let's create a repository.
This way we can use the Task entity to interact with the database!
Declare the Task Repository
Let's create a dedicated package for our repository,
com.devtiro.task.repository. In a typical project you often have multiple
repositories, so this convention keeps things organised.
Now let's create the task repository. This is an interface, which we'll call
TaskRepository:
/** Repository for handling tasks. */
@Repository
public interface TaskRepository extends JpaRepository<Task, UUID> {}That's it! We don't need to create an implementation for this interface, because
the framework does it for us! Better yet, extending JpaRepository gives us
all the functionality we need for this build.
Now let's move on to the service layer.
Summary
- Defined the
TaskRepositoryinterface.