creating uuid type field in Cassandra table using CassandraAdminOperations.createTable

六月ゝ 毕业季﹏ 提交于 2019-12-12 06:23:23

问题


I have problem when create table with UUID type field using CassandraAdminOperations.createTable. I defined field in table with type uuid, but when the table was created using CassandraAdminOperations.createTable, the field was created as timeuuid. Is there any way to force the field to uuid instead of timeuuid ?

Here is the field definition in class,

@PrimaryKeyColumn(name = "id", ordinal = 0, type = PrimaryKeyType.PARTITIONED)
private UUID id;

@Column(value = "url")
private String url;

But when call CassandraAdminOperations.createTable to create the table, the log shows the following and the id filed was created as timeuuid,

00:43:23.877 [localhost-startStop-1] DEBUG o.s.d.c.core.CassandraAdminTemplate - CREATE TABLE IF NOT EXISTS id_to_url_map (id timeuuid, url text, PRIMARY KEY (id));

Thanks!


回答1:


I had the same problem. But after some investigation, I found that you can add @CassandraType annotation, and explicitly specify the class.

    import com.datastax.driver.core.DataType;

    @PrimaryKeyColumn(name = "id", ordinal = 0, type = PrimaryKeyType.PARTITIONED)
    @CassandraType(type = DataType.Name.UUID)
    private UUID id;


来源:https://stackoverflow.com/questions/33153983/creating-uuid-type-field-in-cassandra-table-using-cassandraadminoperations-creat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!