@Repository annotation
Repository components are Java classes marked with the @Repository
annotation. This is a special Spring component that is used for interacting with databases.
@Repository
is a general-purpose stereotype that represents both DDD's Repository and the Java Enterprise Edition (EE) pattern, the Data Access Object (DAO). Developers and teams should handle Repository objects based on the underlying approach. In DDD, a Repository is a central object that carries references to all the objects and should return the reference of a requested object. We need to have all the required dependencies and configurations in place before we start writing classes marked with @Repository
.
We'll use the following libraries as database dependencies:
- H2 database for persisting data: We are going to use H2's memory instance, however, you can also use a file-based instance.
- Hibernate Object Relational Mapping (ORM): For database object mapping.
- Flyway...