use of com.querydsl.sql.dml.SQLInsertClause in project midpoint by Evolveum.
the class AuditInsertion method insertAuditEventRecord.
private MAuditEventRecord insertAuditEventRecord(MAuditEventRecord row) {
QAuditEventRecordMapping aerMapping = QAuditEventRecordMapping.get();
QAuditEventRecord aer = aerMapping.defaultAlias();
SQLInsertClause insert = jdbcSession.newInsert(aer).populate(row);
// Custom columns, this better be replaced by some extension container later
Map<String, ColumnMetadata> customColumns = aerMapping.getExtensionColumns();
for (AuditEventRecordCustomColumnPropertyType property : record.getCustomColumnProperty()) {
if (!customColumns.containsKey(property.getName())) {
throw new IllegalArgumentException("Audit event record table doesn't" + " contains column for property " + property.getName());
}
// Like insert.set, but that one is too parameter-type-safe for our generic usage here.
insert.columns(aer.getPath(property.getName())).values(property.getValue());
}
Long returnedId = insert.executeWithKey(aer.id);
// If returned ID is null, it was likely provided, so we use that one.
row.id = returnedId != null ? returnedId : record.getRepoId();
return row;
}
use of com.querydsl.sql.dml.SQLInsertClause in project midpoint by Evolveum.
the class AuditInsertion method insertAuditDeltas.
private void insertAuditDeltas(MAuditEventRecord auditRow, Collection<MAuditDelta> deltaRows) {
if (deltaRows != null && !deltaRows.isEmpty()) {
SQLInsertClause insertBatch = jdbcSession.newInsert(QAuditDeltaMapping.get().defaultAlias());
for (MAuditDelta deltaRow : deltaRows) {
deltaRow.recordId = auditRow.id;
deltaRow.timestamp = auditRow.timestamp;
// NULLs are important to keep the value count consistent during the batch
insertBatch.populate(deltaRow, DefaultMapper.WITH_NULL_BINDINGS).addBatch();
}
insertBatch.setBatchToBulk(true);
insertBatch.execute();
}
}
Aggregations