@@ -61,29 +61,27 @@ private void processGeneratedKeys(Executor executor, MappedStatement ms, Object
6161 String [] keyProperties = keyStatement .getKeyProperties ();
6262 final Configuration configuration = ms .getConfiguration ();
6363 final MetaObject metaParam = configuration .newMetaObject (parameter );
64- if (keyProperties != null ) {
65- // Do not close keyExecutor.
66- // The transaction will be closed by parent executor.
67- Executor keyExecutor = configuration .newExecutor (executor .getTransaction (), ExecutorType .SIMPLE );
68- List <Object > values = keyExecutor .query (keyStatement , parameter , RowBounds .DEFAULT , Executor .NO_RESULT_HANDLER );
69- if (values .size () == 0 ) {
64+ // Do not close keyExecutor.
65+ // The transaction will be closed by parent executor.
66+ Executor keyExecutor = configuration .newExecutor (executor .getTransaction (), ExecutorType .SIMPLE );
67+ List <Object > values = keyExecutor .query (keyStatement , parameter , RowBounds .DEFAULT , Executor .NO_RESULT_HANDLER );
68+ if (values .size () == 0 ) {
7069 throw new ExecutorException ("SelectKey returned no data." );
71- } else if (values .size () > 1 ) {
70+ } else if (values .size () > 1 ) {
7271 throw new ExecutorException ("SelectKey returned more than one value." );
73- } else {
72+ } else {
7473 MetaObject metaResult = configuration .newMetaObject (values .get (0 ));
7574 if (keyProperties .length == 1 ) {
76- if (metaResult .hasGetter (keyProperties [0 ])) {
77- setValue (metaParam , keyProperties [0 ], metaResult .getValue (keyProperties [0 ]));
78- } else {
79- // no getter for the property - maybe just a single value object
80- // so try that
81- setValue (metaParam , keyProperties [0 ], values .get (0 ));
82- }
75+ if (metaResult .hasGetter (keyProperties [0 ])) {
76+ setValue (metaParam , keyProperties [0 ], metaResult .getValue (keyProperties [0 ]));
77+ } else {
78+ // no getter for the property - maybe just a single value object
79+ // so try that
80+ setValue (metaParam , keyProperties [0 ], values .get (0 ));
81+ }
8382 } else {
84- handleMultipleProperties (keyProperties , metaParam , metaResult );
83+ handleMultipleProperties (keyProperties , metaParam , metaResult );
8584 }
86- }
8785 }
8886 }
8987 } catch (ExecutorException e ) {
0 commit comments