我試圖將java.util.UUID
保存到類型爲timeuuid
的Cassandra列。例如,這是一個默認的spring-data-cassandra映射:http://docs.spring.io/spring-data/cassandra/docs/current/reference/html/#mapping-conversion。 UUID的 值由java.util.UUID#randomUUID()
生成我得到一個異常: "com.datastax.driver.core.exceptions.InvalidQueryException: Invalid version for TimeUUID type"
Cassandra在保存java.util.UUID時說「InvalidQueryException:TimeUUID類型的無效版本」
@Override
public void validate(byte[] bytes)
{
if (bytes.length != 16 && bytes.length != 0)
throw new MarshalException(String.format("TimeUUID should be 16 or 0 bytes (%d)", bytes.length));
// version is bits 4-7 of byte 6.
if (bytes.length > 0)
if ((bytes[6] & 0xf0) != 0x10)
throw new MarshalException("Invalid version for TimeUUID type.");
}