Abhishek :
I have stored an object in redis, say Class StorageConnection,
public void storeSecureConnection(String uniqueKey, Object storageConnection) {
redisTemplateAdmin.opsForValue().set(uniqueKey, storageConnection);
}
Now, I have changed the className from StorageConnection to DataConnection. All the fields and UID remains intact.
It's now giving me an SerializationException on
public DataConnection getAdminDataObject(String uniqueKey) {
return (DataConnection) redisTemplateAdmin.opsForValue().get(uniqueKey);
}
Is there any trick that I can deserialize it with new className?
Edit:
Here's RedisTemplate Initialization:
@Service
public class AdminDataBaseServiceImpl{
private RedisTemplate<String, Object> redisTemplateAdmin;
private HashOperations hashOps;
private AdminDataBaseServiceImpl(RedisTemplate<String, Object> redisTemplateAdmin) {
this.redisTemplateAdmin = redisTemplateAdmin;
hashOps=redisTemplateAdmin.opsForHash();
}
Abhishek :
I used GenericJackson2JsonRedisSerializer
to serialize the object and was storing in redis. To change the class name, I used StringRedisSerializer
to deserialize, changed the classname and again stored in Redis with StringRedisSerializer
.
Then used, as usual, GenericJackson2JsonRedisSerializer
to deserialize the object with new classname. It worked.