public Column[] getSyncKeysColumnsForTable(Table table) { List<String> syncKeys = getSyncKeyNamesAsList(); if (syncKeys.size() > 0) { List<Column> columns = new ArrayList<Column>(); for (String syncKey : syncKeys) { Column col = table.getColumnWithName(syncKey); if (col != null) { columns.add(col); } else { log.error("The sync key column '{}' was specified for the '{}' trigger but was not found in the table", syncKey, triggerId); } } if (columns.size() > 0) { return columns.toArray(new Column[columns.size()]); } else { return table.getPrimaryKeyColumns(); } } else { return table.getPrimaryKeyColumns(); } }
while (rs.next()) { String columnName = rs.getString(1); Column column = table.getColumnWithName(columnName); if (column != null) { column.setAutoIncrement(true);
} else if (table.getColumnWithName(column.getTargetColumnName()) == null) { if (log.isDebugEnabled()) { log.debug("Could not find the target column {}" , column.getTargetColumnName()); boolean addedFirstKey = false; for (int i = 0; i < keyNames.length; i++) { Column targetCol = table.getColumnWithName(keyNames[i]); if (targetCol != null) { columns.add(targetCol);
writer.getBatch().getBinaryEncoding(), pkData, targetTable.getPrimaryKeyColumns()); DmlStatement stmt = writer.getPlatform().createDmlStatement(DmlType.FROM, targetTable); Column column = targetTable.getColumnWithName(columnName); String sql = stmt.getColumnsSql(new Column[] { column });
case USE_TIMESTAMP: lookupColumns = new ArrayList<Column>(); Column versionColumn = targetTable.getColumnWithName(conflict .getDetectExpression()); if (versionColumn != null) {
values.put(auditTable.getColumnWithName(COLUMN_AUDIT_ID).getName(), sequence); values.put(auditTable.getColumnWithName(COLUMN_AUDIT_TIME).getName(), new Date()); values.put(auditTable.getColumnWithName(COLUMN_AUDIT_EVENT).getName(), eventType.getCode()); DmlStatement statement = platform.createDmlStatement(DmlType.INSERT, auditTable); int[] types = statement.getTypes();
case USE_TIMESTAMP: List<Column> lookupColumns = new ArrayList<Column>(); Column versionColumn = targetTable.getColumnWithName(conflict .getDetectExpression()); if (versionColumn != null) {
protected boolean isVersionNewer(Conflict conflict, DatabaseWriter writer, CsvData data) { String columnName = conflict.getDetectExpression(); Table targetTable = writer.getTargetTable(); Table sourceTable = writer.getSourceTable(); String[] pkData = data.getPkData(targetTable); Object[] objectValues = writer.getPlatform().getObjectValues( writer.getBatch().getBinaryEncoding(), pkData, targetTable.getPrimaryKeyColumns()); DmlStatement stmt = writer.getPlatform().createDmlStatement(DmlType.FROM, targetTable); String sql = stmt.getColumnsSql(new Column[] { targetTable.getColumnWithName(columnName) }); Long existingVersion = writer.getTransaction() .queryForObject(sql, Long.class, objectValues); if (existingVersion == null) { return true; } else { Map<String, String> newData = data.toColumnNameValuePairs(sourceTable.getColumnNames(), CsvData.ROW_DATA); Long loadingVersion = Long.valueOf(newData.get(columnName)); return loadingVersion > existingVersion; } }