@@ -51,33 +51,39 @@ 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 :
74
56
Object param = method .convertArgsToSqlCommandParam (args );
75
- result = sqlSession .selectOne (command .getName (), param );
76
- }
77
- } else if (SqlCommandType .FLUSH == command .getType ()) {
57
+ result = rowCountResult (sqlSession .insert (command .getName (), param ));
58
+ break ;
59
+ case UPDATE :
60
+ Object param = method .convertArgsToSqlCommandParam (args );
61
+ result = rowCountResult (sqlSession .update (command .getName (), param ));
62
+ break ;
63
+ case DELETE :
64
+ Object param = method .convertArgsToSqlCommandParam (args );
65
+ result = rowCountResult (sqlSession .delete (command .getName (), param ));
66
+ break ;
67
+ case SELECT :
68
+ if (method .returnsVoid () && method .hasResultHandler ()) {
69
+ executeWithResultHandler (sqlSession , args );
70
+ result = null ;
71
+ } else if (method .returnsMany ()) {
72
+ result = executeForMany (sqlSession , args );
73
+ } else if (method .returnsMap ()) {
74
+ result = executeForMap (sqlSession , args );
75
+ } else if (method .returnsCursor ()) {
76
+ result = executeForCursor (sqlSession , args );
77
+ } else {
78
+ Object param = method .convertArgsToSqlCommandParam (args );
79
+ result = sqlSession .selectOne (command .getName (), param );
80
+ }
81
+ break ;
82
+ case FLUSH :
78
83
result = sqlSession .flushStatements ();
79
- } else {
80
- throw new BindingException ("Unknown execution method for: " + command .getName ());
84
+ break ;
85
+ case default :
86
+ throw new BindingException ("Unknown execution method for: " + command .getName ());
81
87
}
82
88
if (result == null && method .getReturnType ().isPrimitive () && !method .returnsVoid ()) {
83
89
throw new BindingException ("Mapper method '" + command .getName ()
0 commit comments