I've seen people saying its possible like in here.
But there is no implementation, only definition:
@Repository
public interface StudentRepository extends CrudRepository<Student, String>{
Student findByNameAndGender(String name, Gender gender);
}
I've followed the structure used here, where they have:
public interface UserRepository {
void save(User user);
Map<String,User> findAll();
User findById(String id);
void update(User user);
void delete(String id);
}
They don't extend the Repository with CrudRepository
:
extends CrudRepository<Student, String>
And they have the implemented separately like so:
@Repository
public class UserRepositoryImpl implements UserRepository {
private RedisTemplate < String, User > redisTemplate;
private HashOperations hashOperations; //to access Redis cache
public UserRepositoryImpl(RedisTemplate<String, User> redisTemplate) {
this.redisTemplate = redisTemplate;
hashOperations = redisTemplate.opsForHash();
}
@Override
public void save(User user) {
hashOperations.put("USER", user.getId(), user);
}
...
So can you give me an example of an implementation of findByNameAndGender(String name, Gender gender)?