Search in sources :

Example 1 with OfcTaxonVernacularNameRecord

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);
    }
}
Also used : BatchBindStep(org.jooq.BatchBindStep) TaxonVernacularName(org.openforis.idm.model.species.TaxonVernacularName) OfcTaxonVernacularNameRecord(org.openforis.collect.persistence.jooq.tables.records.OfcTaxonVernacularNameRecord)

Aggregations

BatchBindStep (org.jooq.BatchBindStep)1 OfcTaxonVernacularNameRecord (org.openforis.collect.persistence.jooq.tables.records.OfcTaxonVernacularNameRecord)1 TaxonVernacularName (org.openforis.idm.model.species.TaxonVernacularName)1