I am using JOOQ for SQL building in a dynamic way, as I prefer using the good old JDBCTemplate for execution and maintaining myself the domain objects instead of generating them with JOOQ. I have the following batch insert statement: INSERT INTO my_table(field1, field2, ..., field20) values(<VALUES>);
I would like to construct this SQL in a dynamic way. For constructing a select in this manner I have used SelectQuery and methods such as addOrderBy, addConditions, join, etc.
Is there any way to add the column names (i.e. field1, field2, ..., field20) to an InsertQuery? I would like to do something like this:
InsertQuery<Record> insertQuery = ctx.insertQuery(table("my_table"));
insertQuery.addColumns("field1", "field2", ..., "field20");
for (List<Object> values : valuesList) {
insertQuery.addValues(values);
}
getJdbcTemplate().batchUpdate(insertQuery.getSQL(), insertQuery.getValues(), batchSize);