repository
- abstraction over database boilerplate code in [spring]
- auto detects the database driver as found in
pom.xml
- only need to create a factory
- use [[CrudRepository]] as its the highest level of abstraction
- it builds on top of [[Templates]] and is an higher abstraction level when seen from the point of view of [spring-data]
Repository interface
- [spring-data]
- Repository
- JPARepository
- MongoRepository
- CrudRepository
- ReactiveCrudRepository
- PagingAndSortingRepository
all these interfaces define commonly used methods like findAll
, findById
, delete
setup
- first up is to define a repository so that [spring] knows you're using one
- definition is straightforward by declaring an interface extending
CrudRepository
public interface SomeRepository extends CrudRepository<Domain, Long> {}
redis with repository
- if using [repository] to interact with [redis] you don't need to use [redistemplate] and simplify the code
- so it basically saves you from
- providing the serializers for the redis or datastore
- connection factory which although can be autowired from the spring IoC if it's in the classpath
- no need to worry about the complex type conversions like manually providing setters/getters etc
- just add [[@RedisHash]]