Skip to content

The function findByChildId on a Parent repository class is not giving the desired output post v3.2.3 #3126

Open
@torq1993

Description

@torq1993

Class A:

@Getter
@Setter
@RedisHash("Parent")
public class Parent {
    @Indexed
    Long id;

    @Indexed
    String parentColumn1;

    @Indexed
    Child child;
}

Class B:

@Getter
@Setter
@RedisHash("Child")
public class Child {
    @Indexed
    Long id;

    @Indexed
    String childColumn1;
}

Class A Repository:

@Repository
public interface ParentRedisRepository extends CrudRepository<Parent, Long> {
    List<Parent> findByChildId(String id);
}

Test Class:

@SpringBootTest
public class ParentRedisTests {
    @Autowired
    ParentRedisRepository parentRedisRepository;

    @Test
    void fetchParentByChildId(){
        Child child1 = new Child(1L, "childValue1");
        Child child2 = new Child(2L, "childValue2");
        Parent parent1 = new Parent(1L, "parentValue1", child2);
        Parent parent2 = new Parent(2L, "parentValue2", child1);
        Parent parent3 = new Parent(3L, "parentValue3", child1);
        Parent parent4 = new Parent(4L, "parentValue4", child1);
        List<Parent> assertionList = List.of(parent2, parent3, parent4);
        parentRedisRepository.saveAll(List.of(parent1, parent2, parent3, parent4));
        List<Parent> parentList = parentRedisRepository.findByChildId("1");
        assertThat(parentList).containsAnyElementsOf(assertionList); //PASSED in v3.2.3 and FAILED in v3.2.4
    }
}

This repository call used to work till Spring Data Redis v3.2.3, but when I switched to 3.2.4, it did not work as per my requirements. When I monitored the REDIS commands, the following was noticed when I tried to hit the function to fetch by Child ID value 1:

In V3.2.4, the test ran the following command(s):

  • HGETALL Parent:1

In V3.2.3, the test ran the following command(s):

  • SINTER Parent:Child.id:1
  • HGETALL Parent:2
  • HGETALL Parent:3
  • HGETALL Parent:4

Metadata

Metadata

Labels

type: regressionA regression from a previous release

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions