if (parameter != null) {
String keyProperty = ms.getKeyProperty();
final MetaObject metaParam = MetaObject.forObject(parameter);
if (keyProperty != null && metaParam.hasSetter(keyProperty)) {
Class keyPropertyType = metaParam.getSetterType(keyProperty);
TypeHandler th = typeHandlerRegistry.getTypeHandler(keyPropertyType);
if (th != null) {
ResultSet rs = stmt.getGeneratedKeys();
try {
ResultSetMetaData rsmd = rs.getMetaData();
int colCount = rsmd.getColumnCount();
if (colCount > 0) {
String colName = rsmd.getColumnName(1);
while (rs.next()) {
Object value = th.getResult(rs, colName);
metaParam.setValue(keyProperty, value);
}
}
} finally {
try {