Insert multiple rows in Jooq throws compilation error

Viewed 1344

I have a table called VARS that has two columns VAR_NAME and VAR_TYPE. I also have a list of POJOs to insert in this table. The POJO class is called Var and has two fields called varName and varType.

Note that the fields match so Jooq can derive and apply in the insert.

When I try to insert the list of Vars, I get a compilation error:

    InsertSetStep<VarsRecord> insert = create.insertInto(VARS);

    for (Var var: vars) {
        VarsRecord rec = new VarsRecord();
        rec.from(var);
        insert.set(rec);
    }

    insert.execute();   // <-- error here

The error:

The method execute() is undefined for the type InsertSetStep

  • How to run this insert?

  • What should be used instead of InsertSetStep<VarsRecord>?

  • Should I excecute an insertInto for each row?

1 Answers
Related