write UUID in Vertica with jooQ

落爺英雄遲暮 提交于 2021-01-28 18:28:50

问题


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

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