I'm looking for information about how to configure Spring Data JDBC in a Spring Boot app (a Gradle example would be ideal).
I've read through the docs, and I know that I need to define a Repository
implementation for each domain class (or "aggregate" of domain classes), e.g.
interface UserRepository extends CrudRepository<User, Long> {
// custom query methods
long countByLastname(String lastname);
}
But it's not entirely clear what dependencies need to be added, how to inject the repository beans into other beans, how to specify to Spring where the repository beans can be found, etc.
I'd particularly like to see how to define a repository that manages more than one table/domain class. For example a repository that manages persistence of an Order
and it's collection of OrderItem
s. The examples in the docs only show how to map a single domain class to a repository.