use of org.openforis.collect.persistence.jooq.tables.records.OfcDataReportItemRecord in project collect by openforis.
the class DataReportItemDao method insert.
public void insert(DataReport report, List<DataReportItem> items) {
JooqDSLContext dsl = dsl(report);
int nextId = dsl.nextId();
int maxId = nextId;
Insert<OfcDataReportItemRecord> insert = dsl.createInsertStatement();
BatchBindStep batch = dsl.batch(insert);
for (DataReportItem item : items) {
Integer id = item.getId();
if (id == null) {
id = nextId++;
item.setId(id);
}
Object[] values = dsl.extractValues(item);
batch.bind(values);
maxId = Math.max(maxId, id);
}
batch.execute();
dsl.restartSequence(maxId + 1);
}
Aggregations