}
}
private void processGeneratedKeys(Executor executor, MappedStatement ms, Statement stmt, Object parameter) {
try {
final Configuration configuration = ms.getConfiguration();
if (parameter != null) {
String keyStatementName = ms.getId() + SELECT_KEY_SUFFIX;
if (configuration.hasStatement(keyStatementName)) {
if (keyStatement != null) {
String keyProperty = keyStatement.getKeyProperty();
final MetaObject metaParam = configuration.newMetaObject(parameter);
if (keyProperty != null && metaParam.hasSetter(keyProperty)) {
// Do not close keyExecutor.
// The transaction will be closed by parent executor.
Executor keyExecutor = configuration.newExecutor(executor.getTransaction(), ExecutorType.SIMPLE);
List values = keyExecutor.query(keyStatement, parameter, RowBounds.DEFAULT, Executor.NO_RESULT_HANDLER);
if (values.size() > 1) {
throw new ExecutorException("Select statement for SelectKeyGenerator returned more than one value.");
}
metaParam.setValue(keyProperty, values.get(0));