Quantcast
Channel: Active questions tagged redis+java - Stack Overflow
Viewing all articles
Browse latest Browse all 2204

Spring @RedisHash findAll() return null values

$
0
0

I'm using Redis to store students with entity:

@RedisHash("Student")public class Student implements Serializable {    @Id    private Long id;    @Indexed    private String name;    private Integer age;    // getters    // setters    // Constructor with full parameters}

and repository:

@Repositorypublic interface StudentRepository extends CrudRepository<Student, Long> {}

I can save a list of students to Redis database and get that list without any error:

@AutowiredStudentRepository repo;List<Student> students = new ArrayList<>();Student student1 = new Student(........);students.add(student1);Student student2 = new Student(........);students.add(student2);repo.findAll().forEach(){    System.out.println(student);}

The problem is when other project of mine (I'm building apps with micro-service architecture), I use findAll() function to get that list of students, it returns a list of two null elements. If I use findByName(String name), it still returns desired result.

Anyone who used to face this problem can help me, thank you in advanced ?


Viewing all articles
Browse latest Browse all 2204

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>