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

前端 未结 2 2036
伪装坚强ぢ
伪装坚强ぢ 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:26

    On Redis with Spring Boot you just have some queries for finder that are supported like Is, Equals, combine with And, Or , you can take a look on Table 9:

    https://docs.spring.io/spring-data/redis/docs/current/reference/html/#redis.repositories.queries

    UPDATED

    You can create a query following this documentation link as reference

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

    0 讨论(0)
  • 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

    0 讨论(0)
提交回复
热议问题