【发布时间】:2019-06-27 05:34:48
【问题描述】:
我使用 Achilles 库在 Java 中进行对象映射。 Achilles 支持 Cassandra 计数器 (link),但问题是当我进行选择查询时,Counter 类型的字段的值为 null。
这是我的模型:
@Entity(table = "watchs_per_segment")
public class WatchsPerSegment {
@EmbeddedId
private Key key;
@Column
private Counter morning;
@Column
private Counter noon;
@Column
private Counter afternoon;
@Column
private Counter accesspt;
@Column
private Counter night;
public WatchsPerSegment()
{
}
public WatchsPerSegment(Key key, Counter morning, Counter noon,
Counter afternoon, Counter accesspt, Counter night) {
this.key = key;
this.morning = morning;
this.noon = noon;
this.afternoon = afternoon;
this.accesspt = accesspt;
this.night = night;
}
//getters and setters
public static class Key {
@PartitionKey
private String segment;
@ClusteringColumn(value = 1, reversed = true)
private Date day;
@ClusteringColumn(2)
private boolean afterreco;
public Key() {
}
public Key(String segment, Date day, boolean afterreco) {
this.segment = segment;
this.day = day;
this.afterreco = afterreco;
}
//getter and setter
}
查询是:
List<WatchsPerSegment> watchs = manager
.sliceQuery(WatchsPerSegment.class).forSelect()
.withPartitionComponents("253")
.fromClusterings(new Date(2014, 11, 07), true).get();
我打印了结果,所有的计数器都是空的:
WatchsPerSegment [key=Key [segment=253, day=Thu Nov 07 00:00:00 CET 2014, afterreco=true], morning=null, noon=null, afternoon=null, accesspt=null, night=null]
这是跟腱的错误还是我的模型有问题?
【问题讨论】:
-
如果没有看到您的查询、架构或任何详细信息,这将很难回答。
-
你说得对,我更新了我的问题