使用CassandraAdminOperations.createTable在Cassandra表中创建uuid类型字段 [英] creating uuid type field in Cassandra table using CassandraAdminOperations.createTable

查看:105
本文介绍了使用CassandraAdminOperations.createTable在Cassandra表中创建uuid类型字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用CassandraAdminOperations.createTable创建具有UUID类型字段的表时出现问题。我在表中使用uuid类型定义了字段,但是当使用CassandraAdminOperations.createTable创建表时,该字段被创建为timeuuid。有什么办法可以将字段强制为uuid而不是timeuuid吗?

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 ?

这是类中的字段定义,

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

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

但是,当调用CassandraAdminOperations.createTable创建表时,日志显示以下内容,并且ID为创建为timeuuid,

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]调试osdccore.CassandraAdminTemplate-如果不存在,请创建表id_to_url_map(id timeuuid,URL文本,主键(id));

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));

谢谢!

推荐答案

I有同样的问题。但是经过一番调查,我发现您可以添加 @CassandraType 批注,并明确指定该类。

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;

这篇关于使用CassandraAdminOperations.createTable在Cassandra表中创建uuid类型字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆