Custom Spring RedisHash with multiple IDs for a parametrized key

Viewed 165

I have some Redis hash keys which are defined as Class:<class_id>:Student:<student_id>. I'm having trouble defining this parametrized RedisHash in Springboot for keys like this. So far I've only been defining hashes like these which have no issue.

@RedisHash(value = "Class")  // It becomes Redis key Class:1
public class Class implements Serializable {

    @Id
    private Long classId;
    private String className;
    private String classLeaderName;

}

For my required Redis hash, I want to define something like this:

@RedisHash(value = "Class:<class_id>:Student:<student_id>")  // It becomes Redis key Class:1:Student:21
public class ClassStudent implements Serializable {

    @Id
    private Long classId;

    @Id
    private Long studentId;

    private String studentName;
    private String studentSurname;

}

Any help would be greatly appreciated.

0 Answers
Related