用jooQ在Vertica中写UUID [英] write UUID in Vertica with jooQ
问题描述
我没有jOOQ生成的类,因此,我想使用我的类并将其写入vertica.
I don't have jOOQ generated classes, so, I want to use my class and write it to vertica.
Table<Record> table = DSL.table(DATA_TABLE_NAME);
for (Data d : data) {
dsl.insertInto(table, Arrays.asList(
DSL.field(name("uuid"), SQLDataType.UUID)
))
.values(
d.getUuid(),
).execute();
}
在PostgreSql中它可以工作,但是在Vertica中,它会生成此异常
In PostgreSql it works, but in Vertica it generate this exception
[Vertica][VJDBC](2631) ERROR: Column "uuid" is of type uuid but expression is of type varchar
如何在不生成类的情况下编写uuid tu Vertica? d.getUuid()返回java.Util.UUID
How can I write uuid tu Vertica without generated class? d.getUuid() returns java.Util.UUID
推荐答案
UUID
类型在Vertica中相对新颖.从jOOQ 3.13开始,尚不支持它:
https://github.com/jOOQ/jOOQ/issues/10073
The UUID
type is relatively novel in Vertica. As of jOOQ 3.13, it's not yet supported out of the box:
https://github.com/jOOQ/jOOQ/issues/10073
您必须创建自己的此查询的自定义数据类型绑定,并将其附加到您的SQLDataType.UUID
,例如
You'll have to create your own custom data type binding for this query, and attach it to your SQLDataType.UUID
, e.g.
DSL.field(name("uuid"), SQLDataType.UUID.asConvertedDataType(new MyVerticaUUIDBinding()));
这篇关于用jooQ在Vertica中写UUID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!