InsertValuesStep insertStep = context.insertInto(Table, SomeFields);
List<UpdateTableRecord> records = SomeInitialzedRecords();
records.stream().foreach(record -> {
insertStep.values(record.getField1(), record.getField2()...);
insertStep.onDuplicateKeyUpdate().set(Field1, record.getField1());
}
insertStep.execute();
context.batchStore(records).execute();
Hello together,we are currently evaluating Jooq in a prototype context in orderto find out if we can use it later in production. So far it seemspretty nice, with an almost perfect documentation.We need to support different PostgreSql and Sql Server types.One problem we could not yet solve, is the following:We want to insert a batch of 1000 entries into a table. Ifsome entries already exist, we want to update some of the fields instead.We used:
InsertValuesStep insertStep = context.insertInto(Table, SomeFields);
List<UpdateTableRecord> records = SomeInitialzedRecords();
records.stream().foreach(record -> {
insertStep.values(record.getField1(), record.getField2()...);
insertStep.onDuplicateKeyUpdate().set(Field1, record.getField1());
}
insertStep.execute();This works for PostgresSql as expected, but in sql server it does insert only one row per execution instead of 1000.
We also tried:
context.batchStore(records).execute();But this throws the DuplicateKey Exception instead of updating the row entry and it seems somewhat slower than the other option under PostgreSql.
Is this the right way to do what we like to achieve or is there something better ?
getContext()
.loadInto(table)
.batchAll()
.onDuplicateKeyUpdate()
.loadRecords(records)
.fields(fields)
.execute();
--You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
create.select().from(BOOK).where(BOOK.ID.equal(5)).and(BOOK.TITLE.equal("Animal Farm")).fetch();
getContext()
.loadInto(table)
.batchAll()
.onDuplicateKeyUpdate()
.loadRecords(records)
.fields(fields)
.execute();
--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+unsubscribe@googlegroups.com.
Hope this helps,
Lukas
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+unsubscribe@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+unsubscribe@googlegroups.com.