Spring Boot + Cassandra轻量级事务更新

时间:2018-08-04 14:59:15

标签: spring-boot cassandra spring-data-cassandra

有什么方法可以在不编写查询的情况下用轻量级交易实现更新?如何从casandra实现示例

UPDATE cycling.cyclist_name
SET firstname = ‘Roxane’
WHERE id = 4647f6d3-7bd2-4085-8d6c-1229351b5498
IF firstname = ‘Roxxane’;

通过

CassandraOperations cops;
cops.update()

cops.batchOps()

InsertOptions适用于

 InsertOptions
.builder()
.ifNotExists(true)
.build();

1 个答案:

答案 0 :(得分:0)

从2.2开始,他们拥有一个用于指定条件检查官方link的api

public UpdateOptions.UpdateOptionsBuilder ifCondition(Filter condition)
Use light-weight transactions by applying IF condition. Replaces a previous ifCondition(Filter) and ifExists(boolean).
Parameters:
condition - the condition to apply for conditional updates, must not be null.
Returns:
this UpdateOptions.UpdateOptionsBuilder
Since:
2.2