use of org.openforis.collect.persistence.jooq.tables.records.OfcSamplingDesignRecord in project collect by openforis.
the class SamplingDesignDao method insert.
/**
* Inserts the items in batch.
*
* @param taxa
*/
public void insert(List<SamplingDesignItem> items) {
if (items != null && !items.isEmpty()) {
SamplingDesignDSLContext dsl = dsl();
int id = dsl.nextId(OFC_SAMPLING_DESIGN.ID, OFC_SAMPLING_DESIGN_ID_SEQ);
int maxId = id;
Insert<OfcSamplingDesignRecord> query = dsl.createInsertStatement();
BatchBindStep batch = dsl.batch(query);
for (SamplingDesignItem item : items) {
if (item.getId() == null) {
item.setId(id++);
}
Object[] values = dsl.extractValues(item);
batch.bind(values);
maxId = Math.max(maxId, item.getId());
}
batch.execute();
dsl.restartSequence(OFC_SAMPLING_DESIGN_ID_SEQ, maxId + 1);
}
}
Aggregations