【问题标题】:Jooq (java) - Type class org.jooq.impl.UnqualifiedName is not supported in dialect DEFAULTJooq (java) - 方言默认不支持类型类 org.jooq.impl.UnqualifiedName
【发布时间】:2019-08-26 11:22:30
【问题描述】:

你好,我在方法中这样做

public void update(Table table, String tableName){
    ArrayList<Name> firstRowInDslFormat = new ArrayList<>();
    for (Object value : table.getTableDataInRowFormat(false).get(0))
        firstRowInDslFormat.add(DSL.name(value.toString()));

    for (int rowId = 1; rowId < table.getTableDataInRowFormat(false).size(); rowId++) {
        stringBuilder.append("\n" + ctx
             .update(DSL.table(DSL.name(tableName)))
             .set(
                 DSL.row(firstRowInDslFormat), 
                 DSL.row(table.getTableDataInRowFormat(false).get(rowId))
             )
             .where(...).getSQL(ParamType.INLINED) + ";");
    }  
}

getTableDataInRowFormat() 返回 Map(Integer,ArrayList) -> Map(rowId, 字符串中的行列值)

我不知道如何解决它。正如您在 start 方法中看到的那样,我尝试将类型从 String 更改为 Name,但它引发了错误: 引起:org.jooq.exception.SQLDialectNotSupportedException:方言DEFAULT中不支持类型类org.jooq.impl.UnqualifiedName

当我只使用这样的字符串时:

 DSL.row(table.getTableDataInRowFormat(false).get(0)), 
 DSL.row(table.getTableDataInRowFormat(false).get(rowId))).where()...

它可以工作...但它会返回带有 ' ' 的列名,正如您在下面的输出中看到的那样...当我运行它时,它会因为语法而引发错误,其中不应该出现 ' '。

仅使用字符串时的输出:

  1. 更新 New_tab1 设置 'id' = '0', 'name' = 'John' where (id=1);
  2. update New_tab1 set 'id' = '1', 'name' = 'Pierce' where (id=2);

我知道这个主题已经创建,但我认为它有点不同。

【问题讨论】:

    标签: java sql jooq


    【解决方案1】:

    这绝对是 jOOQ API 的一个限制。您应该能够将一组org.jooq.Name 实例(或org.jooq.Select 实例)传递给DSL.row(Collection&lt;?&gt;)。我为此创建了一个问题:https://github.com/jOOQ/jOOQ/issues/8492

    作为一种解决方法,请使用Field&lt;?&gt; 实例,而不是Name 实例:

    ArrayList<Field<?>> firstRowInDslFormat = new ArrayList<>();
    for (Object value : table.getTableDataInRowFormat(false).get(0))
        firstRowInDslFormat.add(DSL.field(DSL.name(value.toString()), value.getClass()));
    

    【讨论】:

      猜你喜欢
      • 2016-10-06
      • 2019-09-02
      • 2013-11-22
      • 2020-09-19
      • 2017-10-15
      • 2022-12-07
      • 1970-01-01
      • 1970-01-01
      • 2021-08-24
      相关资源
      最近更新 更多