0

I have below POJO "MyClass" which is being saved in Redis.

class MyClass {
 @Id
 private String someId;
 
 private GenericAnimalID genericAnimalID;
 
 @Transient
 private GenericAnimal genericAnimal

}

class GenericAnimalId{
                       String variant;
                       String size;
        
            
                }
class SpecificAnimalId extends GenericAnimalId{
                       String someProperty;
            
                }
class GenericAnimal{
                   @Id
                   GenericAnimalId genericAnimalId;
        
                   String name;
        
            }

So,basically I am storing MyClass in redis which has "genericAnimalID" property.

Now,when I store some Id having type of SpecificAnimalId,an extra property gets inserted in Redis as

{
genericAnimalId._class : package.SpecificAnimalId,
genericAnimalId : tiger
}

Whereas,when I store Id of type GenericAnimalId,it works fine and only inserts the Id value what I expect.

{
"genericAnimalId":animal
}

In first case,it causes converter issues while reading this value.While in second case,no extra property gets inserted and code works fine after this.

coredev
  • 11
  • 3

0 Answers0