简体   繁体   English

SQL到JOOQ的转换:类型错误

[英]SQL to JOOQ translation: type error

I'm trying to translate the following SQL statement into JOOQ: 我正在尝试将以下SQL语句转换为JOOQ:

UPDATE training_content
SET indx = (
    SELECT SUM(indx)
    FROM training_content
    WHERE indx = ? OR indx = ?
) - indx
WHERE indx = ? OR indx = ?;

The sqlite database looks like this: sqlite数据库如下所示:

CREATE TABLE training_content (
  training_id INTEGER NOT NULL,
  set_id INTEGER NOT NULL,
  indx INTEGER NOT NULL,
  FOREIGN KEY(training_id) REFERENCES training(training_id) ON DELETE CASCADE ON UPDATE CASCADE,
  FOREIGN KEY(set_id) REFERENCES sets(set_id) ON DELETE CASCADE ON UPDATE CASCADE
);

The sql statement swaps two indexes and is used to arrange set objects in a list and is called like this: sql语句交换两个索引,用于在列表中排列集合对象,其调用方式如下:

public void updateIndex(Training t, int index, boolean up) throws SQLException {
    updateIndexStmt.setInt(1, index);
    updateIndexStmt.setInt(2, index + (up ? -1 : 1));
    updateIndexStmt.setInt(3, index);
    updateIndexStmt.setInt(4, index + (up ? -1 : 1));
    updateIndexStmt.executeUpdate();
}

Since i'm moving from plain JDBC to JOOQ i tried to translate it into this: 由于我从纯JDBC迁移到JOOQ,因此我尝试将其转换为:

public void updateIndex(Training t, int index, boolean up) throws SQLException {
    create.update(TRAINING_CONTENT)
            .set(TRAINING_CONTENT.INDX,
                    DSL.select(DSL.sum(TRAINING_CONTENT.INDX).minus(TRAINING_CONTENT.INDX))
                            .from(TRAINING_CONTENT)
                            .where(TRAINING_CONTENT.INDX.equal(index)
                                    .or(TRAINING_CONTENT.INDX.equal(index + (up ? -1 : +1))))
            );
}

But I get the weirdest and longest error message I have ever gotten in Java: 但是我收到了我在Java中获得的最奇怪,最长的错误消息:

Error:(50, 17) java: no suitable method found for set(org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer>,org.jooq.SelectConditionStep<org.jooq.Record1<java.math.BigDecimal>>)
method org.jooq.UpdateSetStep.<T>set(org.jooq.Field<T>,T) is not applicable
  (inference variable T has incompatible bounds
    equality constraints: java.lang.Integer
    lower bounds: org.jooq.SelectConditionStep<org.jooq.Record1<java.math.BigDecimal>>)
method org.jooq.UpdateSetStep.<T>set(org.jooq.Field<T>,org.jooq.Field<T>) is not applicable
  (cannot infer type-variable(s) T
    (argument mismatch; org.jooq.SelectConditionStep<org.jooq.Record1<java.math.BigDecimal>> cannot be converted to org.jooq.Field<T>))
method org.jooq.UpdateSetStep.<T>set(org.jooq.Field<T>,org.jooq.Select<? extends org.jooq.Record1<T>>) is not applicable
  (inferred type does not conform to equality constraint(s)
    inferred: java.math.BigDecimal
    equality constraints(s): java.math.BigDecimal,java.lang.Integer)
method org.jooq.UpdateSetFirstStep.<T1>set(org.jooq.Row1<T1>,org.jooq.Row1<T1>) is not applicable
  (cannot infer type-variable(s) T1
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row1<T1>))
method org.jooq.UpdateSetFirstStep.<T1,T2>set(org.jooq.Row2<T1,T2>,org.jooq.Row2<T1,T2>) is not applicable
  (cannot infer type-variable(s) T1,T2
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row2<T1,T2>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3>set(org.jooq.Row3<T1,T2,T3>,org.jooq.Row3<T1,T2,T3>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row3<T1,T2,T3>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4>set(org.jooq.Row4<T1,T2,T3,T4>,org.jooq.Row4<T1,T2,T3,T4>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row4<T1,T2,T3,T4>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5>set(org.jooq.Row5<T1,T2,T3,T4,T5>,org.jooq.Row5<T1,T2,T3,T4,T5>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row5<T1,T2,T3,T4,T5>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5,T6>set(org.jooq.Row6<T1,T2,T3,T4,T5,T6>,org.jooq.Row6<T1,T2,T3,T4,T5,T6>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5,T6
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row6<T1,T2,T3,T4,T5,T6>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5,T6,T7>set(org.jooq.Row7<T1,T2,T3,T4,T5,T6,T7>,org.jooq.Row7<T1,T2,T3,T4,T5,T6,T7>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5,T6,T7
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row7<T1,T2,T3,T4,T5,T6,T7>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5,T6,T7,T8>set(org.jooq.Row8<T1,T2,T3,T4,T5,T6,T7,T8>,org.jooq.Row8<T1,T2,T3,T4,T5,T6,T7,T8>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5,T6,T7,T8
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row8<T1,T2,T3,T4,T5,T6,T7,T8>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5,T6,T7,T8,T9>set(org.jooq.Row9<T1,T2,T3,T4,T5,T6,T7,T8,T9>,org.jooq.Row9<T1,T2,T3,T4,T5,T6,T7,T8,T9>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5,T6,T7,T8,T9
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row9<T1,T2,T3,T4,T5,T6,T7,T8,T9>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>set(org.jooq.Row10<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>,org.jooq.Row10<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5,T6,T7,T8,T9,T10
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row10<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>set(org.jooq.Row11<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>,org.jooq.Row11<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row11<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>set(org.jooq.Row12<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>,org.jooq.Row12<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row12<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>set(org.jooq.Row13<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>,org.jooq.Row13<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row13<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>set(org.jooq.Row14<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>,org.jooq.Row14<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row14<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>set(org.jooq.Row15<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>,org.jooq.Row15<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row15<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>set(org.jooq.Row16<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>,org.jooq.Row16<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row16<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17>set(org.jooq.Row17<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17>,org.jooq.Row17<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row17<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18>set(org.jooq.Row18<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18>,org.jooq.Row18<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row18<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19>set(org.jooq.Row19<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19>,org.jooq.Row19<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row19<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20>set(org.jooq.Row20<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20>,org.jooq.Row20<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row20<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21>set(org.jooq.Row21<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21>,org.jooq.Row21<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row21<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22>set(org.jooq.Row22<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22>,org.jooq.Row22<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row22<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22>))
method org.jooq.UpdateSetFirstStep.<T1>set(org.jooq.Row1<T1>,org.jooq.Select<? extends org.jooq.Record1<T1>>) is not applicable
  (cannot infer type-variable(s) T1
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row1<T1>))
method org.jooq.UpdateSetFirstStep.<T1,T2>set(org.jooq.Row2<T1,T2>,org.jooq.Select<? extends org.jooq.Record2<T1,T2>>) is not applicable
  (cannot infer type-variable(s) T1,T2
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row2<T1,T2>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3>set(org.jooq.Row3<T1,T2,T3>,org.jooq.Select<? extends org.jooq.Record3<T1,T2,T3>>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row3<T1,T2,T3>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4>set(org.jooq.Row4<T1,T2,T3,T4>,org.jooq.Select<? extends org.jooq.Record4<T1,T2,T3,T4>>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row4<T1,T2,T3,T4>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5>set(org.jooq.Row5<T1,T2,T3,T4,T5>,org.jooq.Select<? extends org.jooq.Record5<T1,T2,T3,T4,T5>>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row5<T1,T2,T3,T4,T5>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5,T6>set(org.jooq.Row6<T1,T2,T3,T4,T5,T6>,org.jooq.Select<? extends org.jooq.Record6<T1,T2,T3,T4,T5,T6>>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5,T6
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row6<T1,T2,T3,T4,T5,T6>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5,T6,T7>set(org.jooq.Row7<T1,T2,T3,T4,T5,T6,T7>,org.jooq.Select<? extends org.jooq.Record7<T1,T2,T3,T4,T5,T6,T7>>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5,T6,T7
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row7<T1,T2,T3,T4,T5,T6,T7>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5,T6,T7,T8>set(org.jooq.Row8<T1,T2,T3,T4,T5,T6,T7,T8>,org.jooq.Select<? extends org.jooq.Record8<T1,T2,T3,T4,T5,T6,T7,T8>>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5,T6,T7,T8
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row8<T1,T2,T3,T4,T5,T6,T7,T8>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5,T6,T7,T8,T9>set(org.jooq.Row9<T1,T2,T3,T4,T5,T6,T7,T8,T9>,org.jooq.Select<? extends org.jooq.Record9<T1,T2,T3,T4,T5,T6,T7,T8,T9>>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5,T6,T7,T8,T9
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row9<T1,T2,T3,T4,T5,T6,T7,T8,T9>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>set(org.jooq.Row10<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>,org.jooq.Select<? extends org.jooq.Record10<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5,T6,T7,T8,T9,T10
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row10<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>set(org.jooq.Row11<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>,org.jooq.Select<? extends org.jooq.Record11<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row11<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>set(org.jooq.Row12<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>,org.jooq.Select<? extends org.jooq.Record12<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row12<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>set(org.jooq.Row13<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>,org.jooq.Select<? extends org.jooq.Record13<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row13<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>set(org.jooq.Row14<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>,org.jooq.Select<? extends org.jooq.Record14<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row14<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>set(org.jooq.Row15<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>,org.jooq.Select<? extends org.jooq.Record15<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row15<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>set(org.jooq.Row16<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>,org.jooq.Select<? extends org.jooq.Record16<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row16<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17>set(org.jooq.Row17<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17>,org.jooq.Select<? extends org.jooq.Record17<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17>>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row17<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18>set(org.jooq.Row18<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18>,org.jooq.Select<? extends org.jooq.Record18<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18>>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row18<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19>set(org.jooq.Row19<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19>,org.jooq.Select<? extends org.jooq.Record19<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19>>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row19<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20>set(org.jooq.Row20<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20>,org.jooq.Select<? extends org.jooq.Record20<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20>>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row20<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21>set(org.jooq.Row21<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21>,org.jooq.Select<? extends org.jooq.Record21<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21>>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row21<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21>))
method org.jooq.UpdateSetFirstStep.<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22>set(org.jooq.Row22<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22>,org.jooq.Select<? extends org.jooq.Record22<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22>>) is not applicable
  (cannot infer type-variable(s) T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22
    (argument mismatch; org.jooq.TableField<ch.tiim.sco.database.jooq.tables.records.TrainingContentRecord,java.lang.Integer> cannot be converted to org.jooq.Row22<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22>))

EDIT 编辑

This JOOQ code does almost work: 此JOOQ代码几乎可以正常工作:

update(TRAINING_CONTENT)
            .set(TRAINING_CONTENT.INDX,
                    select(sum(t.INDX).minus(TRAINING_CONTENT.INDX).coerce(Integer.class))
                            .from(t)
                            .where(t.INDX.equal(index)
                                    .or(t.INDX.equal(index + (up ? -1 : +1))))
            ).where(TRAINING_CONTENT.INDX.equal(index)
                    .or(TRAINING_CONTENT.INDX.equal(index + (up ? -1 : +1))))

But it generates the following SQL: 但是它生成以下SQL:

update training_content 
set indx = (
  select (sum(t.indx) - training_content.indx)
  from training_content t 
  where (t.indx = 2 or t.indx = 1)
) 
where (training_content.indx = 2 or training_content.indx = 1);

But the part select (sum(t.indx) - training_content.indx) does not work like it should with my original SQL code: it selects for both columns the same value instead of switching them. 但是部分select (sum(t.indx) - training_content.indx)不适用于我的原始SQL代码:它为两列选择相同的值,而不是切换它们。

The error message is indeed a bit misleading as the compiler seems to be listing all the possibly applicable overloaded set() methods. 由于编译器似乎列出了所有可能适用的重载set()方法,因此错误消息确实有点令人误解。 The reason why you're getting a compilation error is because the left side of your set() call is a Field<Integer> : 出现编译错误的原因是因为set()调用的左侧是Field<Integer>

TRAINING_CONTENT.INDX

Whereas the right side is a Select<Record1<BigDecimal>> (Note that DSL.sum() returns a Field<BigDecimal> ) : 右边是Select<Record1<BigDecimal>> (请注意, DSL.sum()返回Field<BigDecimal> ):

DSL.select(DSL.sum(TRAINING_CONTENT.INDX).minus(TRAINING_CONTENT.INDX))

But the set() call signature is like this: 但是set()调用签名是这样的:

<T> UpdateSetMoreStep<R> set(Field<T> field,
                             Select<? extends Record1<T>> value)

The easiest solution would be to coerce your right-hand side also to Integer : 最简单的解决方案是将您的右侧也强制为Integer

DSL.select(DSL.sum(TRAINING_CONTENT.INDX)
              .minus(TRAINING_CONTENT.INDX)
              .coerce(Integer.class))

A note on the query itself 有关查询本身的注释

Your call to minus() won't work like that. 您对minus()调用将无法正常工作。 You will need to alias the TRAINING_CONTENT table in the nested select if you want to refer to the TRAINING_CONTENT.INDX column from the UPDATE statement. 如果要引用UPDATE语句中的TRAINING_CONTENT.INDX列,则需要在嵌套选择中为TRAINING_CONTENT表加上别名。 Like this: 像这样:

TrainingContent t = TRAINING_CONTENT.as("t");

create.update(TRAINING_CONTENT)
      .set(TRAINING_CONTENT.INDX,
           select(sum(t.INDX).minus(TRAINING_CONTENT.INDX))
           .from(t)
           .where(t.INDX.equal(index)
           .or(t.INDX.equal(index + (up ? -1 : +1))))
      );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM