@@ -51,33 +51,42 @@ public MapperMethod(Class<?> mapperInterface, Method method, Configuration confi
51
51
52
52
public Object execute (SqlSession sqlSession , Object [] args ) {
53
53
Object result ;
54
- if (SqlCommandType .INSERT == command .getType ()) {
55
- Object param = method .convertArgsToSqlCommandParam (args );
56
- result = rowCountResult (sqlSession .insert (command .getName (), param ));
57
- } else if (SqlCommandType .UPDATE == command .getType ()) {
58
- Object param = method .convertArgsToSqlCommandParam (args );
59
- result = rowCountResult (sqlSession .update (command .getName (), param ));
60
- } else if (SqlCommandType .DELETE == command .getType ()) {
61
- Object param = method .convertArgsToSqlCommandParam (args );
62
- result = rowCountResult (sqlSession .delete (command .getName (), param ));
63
- } else if (SqlCommandType .SELECT == command .getType ()) {
64
- if (method .returnsVoid () && method .hasResultHandler ()) {
65
- executeWithResultHandler (sqlSession , args );
66
- result = null ;
67
- } else if (method .returnsMany ()) {
68
- result = executeForMany (sqlSession , args );
69
- } else if (method .returnsMap ()) {
70
- result = executeForMap (sqlSession , args );
71
- } else if (method .returnsCursor ()) {
72
- result = executeForCursor (sqlSession , args );
73
- } else {
54
+ switch (command .getType ()) {
55
+ case INSERT : {
56
+ Object param = method .convertArgsToSqlCommandParam (args );
57
+ result = rowCountResult (sqlSession .insert (command .getName (), param ));
58
+ break ;
59
+ }
60
+ case UPDATE : {
61
+ Object param = method .convertArgsToSqlCommandParam (args );
62
+ result = rowCountResult (sqlSession .update (command .getName (), param ));
63
+ break ;
64
+ }
65
+ case DELETE : {
74
66
Object param = method .convertArgsToSqlCommandParam (args );
75
- result = sqlSession .selectOne (command .getName (), param );
67
+ result = rowCountResult (sqlSession .delete (command .getName (), param ));
68
+ break ;
76
69
}
77
- } else if (SqlCommandType .FLUSH == command .getType ()) {
70
+ case SELECT :
71
+ if (method .returnsVoid () && method .hasResultHandler ()) {
72
+ executeWithResultHandler (sqlSession , args );
73
+ result = null ;
74
+ } else if (method .returnsMany ()) {
75
+ result = executeForMany (sqlSession , args );
76
+ } else if (method .returnsMap ()) {
77
+ result = executeForMap (sqlSession , args );
78
+ } else if (method .returnsCursor ()) {
79
+ result = executeForCursor (sqlSession , args );
80
+ } else {
81
+ Object param = method .convertArgsToSqlCommandParam (args );
82
+ result = sqlSession .selectOne (command .getName (), param );
83
+ }
84
+ break ;
85
+ case FLUSH :
78
86
result = sqlSession .flushStatements ();
79
- } else {
80
- throw new BindingException ("Unknown execution method for: " + command .getName ());
87
+ break ;
88
+ default :
89
+ throw new BindingException ("Unknown execution method for: " + command .getName ());
81
90
}
82
91
if (result == null && method .getReturnType ().isPrimitive () && !method .returnsVoid ()) {
83
92
throw new BindingException ("Mapper method '" + command .getName ()
0 commit comments