use of com.querydsl.sql.dml.SQLInsertClause in project querydsl by querydsl.
the class MySQLQueryFactoryTest method insertIgnore.
@Test
public void insertIgnore() {
SQLInsertClause clause = queryFactory.insertIgnore(QSurvey.survey);
assertEquals("insert ignore into SURVEY\nvalues ()", clause.toString());
}
use of com.querydsl.sql.dml.SQLInsertClause in project midpoint by Evolveum.
the class SqlAuditServiceImpl method insertProperties.
private void insertProperties(JdbcSession jdbcSession, long recordId, List<AuditEventRecordPropertyType> properties) {
if (properties.isEmpty()) {
return;
}
QAuditPropertyValue qAuditPropertyValue = QAuditPropertyValueMapping.get().defaultAlias();
SQLInsertClause insertBatch = jdbcSession.newInsert(qAuditPropertyValue);
for (AuditEventRecordPropertyType propertySet : properties) {
for (String value : propertySet.getValue()) {
// id will be generated, but we're not interested in those here
insertBatch.set(qAuditPropertyValue.recordId, recordId).set(qAuditPropertyValue.name, propertySet.getName()).set(qAuditPropertyValue.value, value).addBatch();
}
}
if (insertBatch.getBatchCount() == 0) {
// strange, no values anywhere?
return;
}
insertBatch.setBatchToBulk(true);
insertBatch.execute();
}
use of com.querydsl.sql.dml.SQLInsertClause in project midpoint by Evolveum.
the class SqlAuditServiceImpl method insertReferences.
private void insertReferences(JdbcSession jdbcSession, long recordId, List<AuditEventRecordReferenceType> references) {
if (references.isEmpty()) {
return;
}
QAuditRefValue qAuditRefValue = QAuditRefValueMapping.get().defaultAlias();
SQLInsertClause insertBatch = jdbcSession.newInsert(qAuditRefValue);
for (AuditEventRecordReferenceType refSet : references) {
for (AuditEventRecordReferenceValueType refValue : refSet.getValue()) {
// id will be generated, but we're not interested in those here
PolyStringType targetName = refValue.getTargetName();
insertBatch.set(qAuditRefValue.recordId, recordId).set(qAuditRefValue.name, refSet.getName()).set(qAuditRefValue.oid, refValue.getOid()).set(qAuditRefValue.type, RUtil.qnameToString(refValue.getType())).set(qAuditRefValue.targetNameOrig, PolyString.getOrig(targetName)).set(qAuditRefValue.targetNameNorm, PolyString.getNorm(targetName)).addBatch();
}
}
if (insertBatch.getBatchCount() == 0) {
// strange, no values anywhere?
return;
}
insertBatch.setBatchToBulk(true);
insertBatch.execute();
}
use of com.querydsl.sql.dml.SQLInsertClause in project midpoint by Evolveum.
the class SqlAuditServiceImpl method insertReferences.
private void insertReferences(JdbcSession jdbcSession, long recordId, Map<String, Set<AuditReferenceValue>> references) {
if (references.isEmpty()) {
return;
}
QAuditRefValue qAuditRefValue = QAuditRefValueMapping.get().defaultAlias();
SQLInsertClause insertBatch = jdbcSession.newInsert(qAuditRefValue);
for (String refName : references.keySet()) {
for (AuditReferenceValue refValue : references.get(refName)) {
// id will be generated, but we're not interested in those here
PolyString targetName = refValue.getTargetName();
insertBatch.set(qAuditRefValue.recordId, recordId).set(qAuditRefValue.name, refName).set(qAuditRefValue.oid, refValue.getOid()).set(qAuditRefValue.type, RUtil.qnameToString(refValue.getType())).set(qAuditRefValue.targetNameOrig, PolyString.getOrig(targetName)).set(qAuditRefValue.targetNameNorm, PolyString.getNorm(targetName)).addBatch();
}
}
if (insertBatch.getBatchCount() == 0) {
// strange, no values anywhere?
return;
}
insertBatch.setBatchToBulk(true);
insertBatch.execute();
}
use of com.querydsl.sql.dml.SQLInsertClause in project midpoint by Evolveum.
the class SqlAuditServiceImpl method insertAuditDeltas.
private void insertAuditDeltas(JdbcSession jdbcSession, MAuditEventRecord auditRow, List<ObjectDeltaOperationType> deltas) {
// we want to keep only unique deltas, checksum is also part of PK
Map<String, MAuditDelta> deltasByChecksum = new HashMap<>();
for (ObjectDeltaOperationType delta : deltas) {
if (delta == null) {
continue;
}
MAuditDelta mAuditDelta = convertDelta(delta, auditRow);
deltasByChecksum.put(mAuditDelta.checksum, mAuditDelta);
}
if (!deltasByChecksum.isEmpty()) {
SQLInsertClause insertBatch = jdbcSession.newInsert(QAuditDeltaMapping.get().defaultAlias());
for (MAuditDelta value : deltasByChecksum.values()) {
// NULLs are important to keep the value count consistent during the batch
insertBatch.populate(value, DefaultMapper.WITH_NULL_BINDINGS).addBatch();
}
insertBatch.setBatchToBulk(true);
insertBatch.execute();
}
}
Aggregations