Uploaded image for project: 'Spring Data Redis'
  1. Spring Data Redis
  2. DATAREDIS-925

Support secondary index for attribute with UUID type

    Details

      Description

      I have defined a object model such as "person" to include a field "tenant" as UUID type, I want to annotate with "Indexed" so I can query person by tenant

      
      @RedisHash("Person")
      public class Person implements Serializable {
         @Id
         String id;
      
         @Indexed
         UUID tenant;
      
         @Indexed
         String email;
      }
      
      
      

      I added two persons by calling PersonRepository.save(person) with the same tenant UUID with different email.

      Then I have following repository that defines two custom queries where first query using tenant (UUID) return empty (I expected two) while second query using email return one person that is expected.

      @Repository public interface PersonRespository extends CrudRepository<Person, String>

      { List<Person> findByTenantAndEmail(UUID tenant, String email); //return empty List<Person> findByEmail(String email);//this one works fine }

      It looks like framework does not index UUID type as I found out through debugging that PathIndexResolver will try to index UUID.mostSigBits  and UUID.leastSigBits.

      I was able to workaround that by handling UUID type handling inside PathIndexResolver#Set<IndexedData> doResolveIndexesFor(..), but that method is private and I have to copy the code block in the extended class. I wonder if you can make the following enhancement:

      1. Support UUID for secondary index inside the framework
      2. or make PathIndexResolver#Set<IndexedData> doResolveIndexesFor(..) method protected instead of private so developer can handle custom object when dealing with secondary index.

        Attachments

          Activity

            People

            • Assignee:
              cstrobl Christoph Strobl
              Reporter:
              bchen819 Ben
              Last updater:
              Oliver Drotbohm
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: