我正在尝试保存java.util.UUID
到 Cassandra 类型的列timeuuid
。例如,这是一个默认的 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"
@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.");
}