《Spring Data 官方文件》5.6 儲存, 更新, 以及刪除資料行
阿新 • • 發佈:2018-12-22
package org.spring.cassandra.example; import java.io.Serializable; import java.util.Date; import org.springframework.cassandra.core.Ordering; import org.springframework.cassandra.core.PrimaryKeyType; import org.springframework.data.cassandra.mapping.PrimaryKeyClass; import org.springframework.data.cassandra.mapping.PrimaryKeyColumn; @PrimaryKeyClass public class LoginEventKey implements Serializable { @PrimaryKeyColumn(name = "person_id", ordinal = 0, type = PrimaryKeyType.PARTITIONED) private String personId; @PrimaryKeyColumn(name = "event_time", ordinal = 1, type = PrimaryKeyType.CLUSTERED, ordering = Ordering.DESCENDING) private Date eventTime; public String getPersonId() { return personId; } public void setPersonId(String personId) { this.personId = personId; } public Date getEventTime() { return eventTime; } public void setEventTime(Date eventTime) { this.eventTime = eventTime; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((eventTime == null) ? 0 : eventTime.hashCode()); result = prime * result + ((personId == null) ? 0 : personId.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; LoginEventKey other = (LoginEventKey) obj; if (eventTime == null) { if (other.eventTime != null) return false; } else if (!eventTime.equals(other.eventTime)) return false; if (personId == null) { if (other.personId != null) return false; } else if (!personId.equals(other.personId)) return false; return true; } }