Closed ergunp closed 5 years ago
@ergunp how were you able to fix this?
@gnumilanix I used a completely different approach as what was doing initially was wrong.
I am trying to configure RedisCacheManager
and having a similar issue with GenericJackson2JsonRedisSerializer
. Either the one mentioned above or LinkedHashMap cannot be cast to com.x.y.z
. This only happens when using @Cacheable
annotation.
Are you able to configure it correctly with cache annotations? Or using RedisTemplate
directly. Would you mind sharing your approach?
I am also facing the same problem. Would you mind sharing your approach? +1
After spending many days trying to find a solution, I had to finally look for an alternative. I don't remember everything but, I will try to summarize.
I use JPA interface projection, which was convenient as it mapped all sub-entities automatically. However, it returns a proxy and not actual implementation. (Which is why I ended up in this spot)
I did try to unwrap the proxy, which did give me the correct type but, I found it way to much hassle to unwrap all sub and nested objects. Which is why GenericJackson2JsonRedisSerializer
would always end up setting id as a Proxy for all those sub and nested objects, instead of the actual type.
Since I didn't have to cache all these interfaces anyways, I changed the ones that I had to cache to use Class/DTO based projection instead. Of course, that results in having to map sub-entities manually. But finally, I was able to cache using JdkSerializationRedisSerializer
.
I hope some other day, someone can share a better solution to this problem.
I am storing my object as json in redis cache using the
GenericJackson2JsonRedisSerializer()
But my issue is when I try to update the object within the cache I get the following error
I have already tried adding the following to my object.
but with no luck.
Here is my config,
this is my object
Here is how i am updating my object in the cache
Any help would be much appreciated.