use of org.openforis.collect.persistence.jooq.tables.records.OfcTaxonVernacularNameRecord in project collect by openforis.
the class TaxonVernacularNameDao method insert.
public void insert(List<TaxonVernacularName> items) {
if (items != null && !items.isEmpty()) {
TaxonVernacularNameDSLContext dsl = dsl();
int id = dsl.nextId(OFC_TAXON_VERNACULAR_NAME.ID, OFC_TAXON_VERNACULAR_NAME_ID_SEQ);
int maxId = id;
Insert<OfcTaxonVernacularNameRecord> query = dsl.createInsertStatement();
BatchBindStep batch = dsl.batch(query);
for (TaxonVernacularName 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_TAXON_VERNACULAR_NAME_ID_SEQ, maxId + 1);
}
}
Aggregations