Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
torq1993 opened this issue Mar 28, 2025 · 0 comments
Assignees
Labels
type: regression A regression from a previous release

Comments

@torq1993
Copy link

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
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 28, 2025
@mp911de mp911de added type: regression A regression from a previous release and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: regression A regression from a previous release
Projects
None yet
Development

No branches or pull requests

4 participants