我正在使用spring-data-cassandra
,并且有一个这样的表其主要密钥是CCD_ 2。int_col1
&int_col2
是分区键bigint_col1
&bigint_col2
是集群密钥。
实施hashcode
&equals
方法。我上面的@PrimaryKeyClass
的hashcode
实现应该是什么
// your class's constructor should have exactly four arguments
// and ensure that each of these four fields are non-null
@Override
public int hashCode() {
return 37
^ int_col1.hashCode()
^ int_col2.hashCode()
^ bigint_col1.hashCode()
^ bigint_col2.hashCode();
}
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (!(that instanceof YourPrimaryKeyClass)) {
return false;
}
YourPrimaryKeyClass other = (YourPrimaryKeyClass) that;
return this.int_col1.equals(other.int_col1)
&& this.int_col2.equals(other.int_col2)
&& bigint_col1.equals(other.bigint_col1)
&& bigint_col2.equals(other.bigint_col2);
}