Caused by: java.lang.IllegalArgumentException: CONTAINING (1): [IsContaining, Containing, Contains]is not supported for redis query derivation - Redis

前端 未结 2 2058
伪装坚强ぢ
伪装坚强ぢ 2021-01-17 00:53

I\'m developing Spring Boot + Redis example. In this example, I\'ve developed some custom methods which pull details based on RoleName. For the below method

2条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-17 01:52

    Ok lets start from "How Redis Work"

    Redis work on Hashes for ID which helps in faster location of record. @Indexed is also hashed and stored for faster pin-pointing the record

    So By Default for MiddleName the "contain" query will not work as Hash for "Test" string will not be contained in Hash for String "TestUser".

    But ExampleMatcher is here to the rescue.

    Source: https://docs.spring.io/spring-data/redis/docs/2.1.2.RELEASE/reference/html/#query-by-example

    Solution for RoleName search on Role Object is relatively simple: Use this query

    userRepository.findByRoleRoleName("ADMIN") (Basically remove the underscore)

    And good news is that it can be combined with the above ExampleMatcher.

    Let's discuss if you have doubt.

    Helpfull Reference for RoleName search : Query Nested Objects in Redis using Spring Data

提交回复
热议问题