Description
If i set a literal value in column mapping:
<Jdbc name="..." tableName="..." ....>
<DataSource jndiName="...." />
<ColumnMapping name="...." />
<ColumnMapping name="my_col" literal="'my_value'" />
....
generated sql is wrong:
INSERT INTO ... (..) VALUES (?, ... 'myvalue'?, ...)
I think the problem should be in class JdbcDatabaseManager, row 374. Maybe an else is missing. Please check.
for (final ColumnMapping mapping : data.columnMappings) {
final String mappingName = mapping.getName();
if (Strings.isNotEmpty(mapping.getLiteralValue())) {
logger().trace("Adding INSERT VALUES literal for ColumnMapping[{}]: {}={} ", i, mappingName, mapping.getLiteralValue());
sb.append(mapping.getLiteralValue());
}
*** missing else *** if (Strings.isNotEmpty(mapping.getParameter())) {
logger().trace("Adding INSERT VALUES parameter for ColumnMapping[{}]: {}={} ", i, mappingName, mapping.getParameter());
sb.append(mapping.getParameter());
columnMappings.add(mapping);
} else {
logger().trace("Adding INSERT VALUES parameter marker for ColumnMapping[{}]: {}={} ", i, mappingName, PARAMETER_MARKER);
sb.append(PARAMETER_MARKER);
columnMappings.add(mapping);
}
sb.append(',');
i++;
}