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

RedisCommandExecutionException: WRONGTYPE Operation against a key holding the wrong kind of value

$
0
0
@Data@Setter@Getter@Builder@AllArgsConstructor@NoArgsConstructor@RedisHash("ABC")public class ABCRedisEntity implements Serializable{   @Id   private String identification;   private String anotherAttribute;   private String insertDate;   private String lastChange;}
@Repositorypublic interface RedisABCRepository extends JpaRepository<ABCRedisEntity, String>{}

I save the object with:

redisABCRepository.save(abc);

I used those libs:

implementation "org.springframework.boot:spring-boot-starter-data-jpa:2.6.6"implementation "org.springframework.boot:spring-boot-starter-data-redis:2.6.6"

My DatabaseConfig:

@Configuration@EnableRedisRepositories(basePackages = "path.to.package.databaseclient.redis", enableKeyspaceEvents = RedisKeyValueAdapter.EnableKeyspaceEvents.ON_STARTUP)@EnableJpaRepositories(basePackages = "path.to.package.databaseclient.jpa")@EntityScan("path.to.package")@EnableRetry@ComponentScan@Slf4jpublic class DatabaseClientAutoconfiguration{   public DatabaseClientAutoconfiguration()   {      log.info("Adapter database-client loaded...");   }   @Bean   public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory)   {      RedisTemplate<String, Object> template = new RedisTemplate<>();      template.setConnectionFactory(redisConnectionFactory);      template.setKeySerializer(new StringRedisSerializer());      template.setHashKeySerializer(new StringRedisSerializer());      template.setValueSerializer(new JdkSerializationRedisSerializer());      template.setHashKeySerializer(new JdkSerializationRedisSerializer());      template.setEnableTransactionSupport(true);      template.afterPropertiesSet();      return template;   } 

The object is saved but i got the exception and the code is interrupted:

2023.07.31 12:55:27.221 [http-nio-4603-exec-1] WARN  d.s.a.b.a.r.e.RestExceptionHandlerAdvice:71 - Error in execution; nested exception is io.lettuce.core.RedisCommandExecutionException: WRONGTYPE Operation against a key holding the wrong kind of value

Viewing all articles
Browse latest Browse all 2206

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>