Quantcast
Channel: Active questions tagged redis+java - Stack Overflow
Viewing all articles
Browse latest Browse all 2204

Spring boot app unnecessarily adds _class property in redis

$
0
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.


Viewing all articles
Browse latest Browse all 2204

Trending Articles