in rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ChangeFactory.java [149:193]
private UpdateCommandImpl getUpdateCommand(DataObject changedObject) {
UpdateCommandImpl command = null;
if (updateCommand == null) {
Table table = mapping.getTableByTypeName(changedObject.getType().getName());
if (table == null) {
if (changedObject.getType().getProperty("ID") != null) {
mapping.addPrimaryKey(changedObject.getType().getName() + ".ID");
table = mapping.getTableByTypeName(changedObject.getType().getName());
} else {
throw new RuntimeException("Table " + changedObject.getType().getName()
+ " was changed in the DataGraph but is not present in the Config");
}
}
Update update = table.getUpdate();
if (update == null) {
command = UpdateGenerator.INSTANCE.getUpdateCommand(mapping, changedObject, table);
} else {
// command can be cached
TableWrapper t = new TableWrapper(table);
if (t.getCollisionColumn() != null) {
updateCommand = new OptimisticWriteCommandImpl(update);
} else {
updateCommand = new UpdateCommandImpl(update);
}
command = updateCommand;
}
if (command != null) {
command.setConnection(connection);
command.configWrapper = mapping;
} else {
if(this.logger.isDebugEnabled()) {
this.logger.debug("Update command is NULL");
}
}
} else {
command = updateCommand;
}
if (this.logger.isDebugEnabled()) {
this.logger.debug("Returning updateCommand: " + command);
}
return command;
}