if (value == null) {
for (int j = 0; j < columns.length; j++) {
stmt.setNull(count++, columns[j].getSqlType());
}
} else if (value instanceof Identity) {
Identity id = (Identity) value;
if (id.size() != columns.length) {
throw new PersistenceException("Size of identity field mismatch!");
}
for (int j = 0; j < columns.length; j++) {
SQLTypeInfos.setValue(stmt, count++,
columns[j].toSQL(id.get(j)), columns[j].getSqlType());
}
} else {
if (columns.length != 1) {
throw new PersistenceException("Complex field expected!");
}
SQLTypeInfos.setValue(stmt, count++, columns[0].toSQL(value),
columns[0].getSqlType());
}
}
}
// bind the identity of the row to be stored into the preparedStatement
SQLColumnInfo[] ids = _engine.getColumnInfoForIdentities();
if (identity.size() != ids.length) {
throw new PersistenceException("Size of identity field mismatched!");
}
for (int i = 0; i < ids.length; i++) {
stmt.setObject(count++, ids[i].toSQL(identity.get(i)));
if (LOG.isTraceEnabled()) {
LOG.trace(Messages.format("jdo.bindingIdentity", ids[i].getName(),
ids[i].toSQL(identity.get(i))));
}
}
// bind the old fields of the row to be stored into the preparedStatement
if (oldentity.getFields() != null) {
boolean supportsSetNull = _factory.supportsSetNullInWhere();
for (int i = 0; i < fields.length; ++i) {
if (fields[i].isStore() && fields[i].isDirtyCheck()) {
SQLColumnInfo[] columns = fields[i].getColumnInfo();
Object value = oldentity.getField(i);
if (value == null) {
if (supportsSetNull) {
for (int j = 0; j < columns.length; j++) {
stmt.setNull(count++, columns[j].getSqlType());
}
}
} else if (value instanceof Identity) {
Identity id = (Identity) value;
if (id.size() != columns.length) {
throw new PersistenceException(
"Size of identity field mismatch!");
}
for (int j = 0; j < columns.length; j++) {
SQLTypeInfos.setValue(stmt, count++,
columns[j].toSQL(id.get(j)), columns[j].getSqlType());
if (LOG.isTraceEnabled()) {
LOG.trace(Messages.format("jdo.bindingField",
columns[j].getName(), columns[j].toSQL(id.get(j))));
}
}
} else {
if (columns.length != 1) {
throw new PersistenceException("Complex field expected!");