Reputation: 181
I'm trying to translate the following SQL statement into 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:
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:
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:
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:
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>))
This JOOQ code does almost work:
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:
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.
Upvotes: 1
Views: 1951
Reputation: 220762
The error message is indeed a bit misleading as the compiler seems to be listing all the possibly applicable overloaded set()
methods. The reason why you're getting a compilation error is because the left side of your set()
call is a Field<Integer>
:
TRAINING_CONTENT.INDX
Whereas the right side is a Select<Record1<BigDecimal>>
(Note that DSL.sum()
returns a Field<BigDecimal>
) :
DSL.select(DSL.sum(TRAINING_CONTENT.INDX).minus(TRAINING_CONTENT.INDX))
But the set()
call signature is like this:
<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
:
DSL.select(DSL.sum(TRAINING_CONTENT.INDX)
.minus(TRAINING_CONTENT.INDX)
.coerce(Integer.class))
Your call to minus()
won't work like that. 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. 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))))
);
Upvotes: 1