我正在尝试为每个列添加TTL,同时使用spring boot应用程序插入和更新数据.为此我使用spring-data-cassandra 1.1.3.RELEASE
为此,我编写了一个接口CustomTTLRepository:
@NoRepositoryBean
public interface CustomTTLRepository<T, ID extends Serializable> extends TypedIdCassandraRepository<T, ID> {
<S extends T> S save(S s, int ttl);
}
Run Code Online (Sandbox Code Playgroud)
实现CustomTTLRepositoryImpl:
@NoRepositoryBean
public class CustomTTLRepositoryImpl<T, ID extends Serializable> extends SimpleCassandraRepository<T, ID> implements CustomTTLRepository<T, ID> {
public CustomTTLRepositoryImpl(CassandraEntityInformation<T, ID> metadata, CassandraTemplate template) {
super(metadata, template);
this.entityInformation = metadata;
this.template = template;
}
@Override
public <S extends T> S save(S s, int ttl) {
WriteOptions writeOptions=new WriteOptions();
writeOptions.setTtl(ttl);
return template.insert(s, writeOptions);
}
Run Code Online (Sandbox Code Playgroud)
}
但是,当我尝试部署此应用程序时,我收到以下错误:
Caused by: java.lang.IllegalArgumentException: encountered …Run Code Online (Sandbox Code Playgroud)