else{
statement.append(table.getTableName());
}
statement.append(" set ");
ChangeSummary summary = changedObject.getDataGraph().getChangeSummary();
HashSet changedFields = getChangedFields(mapping, summary, changedObject, tableWrapper);
Iterator i = changedFields.iterator();
int idx = 1;
while (i.hasNext()) {
Property property = (Property) i.next();
Column c = tableWrapper.getColumnByPropertyName(property.getName());
if ((c == null) || !c.isCollision() || !c.isPrimaryKey()) {
String columnName = c == null ? property.getName() : c.getColumnName();
appendFieldSet(statement, idx > 1, columnName);
parameters.add(createParameter(tableWrapper, property, idx++));
}
}
Column c = tableWrapper.getManagedColumn();
if (c != null) {
appendFieldSet(statement, idx > 1, c.getColumnName());
String propertyName = c.getPropertyName() == null ? c.getColumnName() : c.getPropertyName();
parameters.add(createManagedParameter(tableWrapper,
changedObject.getInstanceProperty(propertyName), idx++));
}
statement.append(" where ");
Iterator pkColumnNames = tableWrapper.getPrimaryKeyNames().iterator();
Iterator pkPropertyNames = tableWrapper.getPrimaryKeyProperties().iterator();
while (pkColumnNames.hasNext() && pkPropertyNames.hasNext()) {
String columnName = (String) pkColumnNames.next();
String propertyName = (String) pkPropertyNames.next();
statement.append(columnName);
statement.append(" = ?");
if (pkColumnNames.hasNext() && pkPropertyNames.hasNext()) {
statement.append(" and ");
}
parameters.add(createParameter(tableWrapper, type.getProperty(propertyName), idx++));
}
if (tableWrapper.getCollisionColumn() == null) {
Iterator iter = changedFields.iterator();
while (iter.hasNext()) {
statement.append(" and ");
Property changedProperty = (Property) iter.next();
Column column = tableWrapper.getColumnByPropertyName(changedProperty.getName());
statement.append(column == null ? changedProperty.getName() : column.getColumnName());
Object value;
Setting setting = summary.getOldValue(changedObject, changedProperty);
// Setting is null if this is a relationship change
if (setting == null) {
value = changedObject.get(changedProperty);
} else {
value = setting.getValue();