问题
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();
}
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
How can I write uuid tu Vertica without generated class? d.getUuid() returns java.Util.UUID
回答1:
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
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()));
来源:https://stackoverflow.com/questions/61226843/write-uuid-in-vertica-with-jooq