Exemplo n.º 1
0
 private <K, V> Map<K, V> executeForMap(SqlSession sqlSession, Object[] args) {
   Map<K, V> result;
   Object param = method.convertArgsToSqlCommandParam(args);
   if (method.hasRowBounds()) {
     RowBounds rowBounds = method.extractRowBounds(args);
     result = sqlSession.<K, V>selectMap(command.getName(), param, method.getMapKey(), rowBounds);
   } else {
     result = sqlSession.<K, V>selectMap(command.getName(), param, method.getMapKey());
   }
   return result;
 }
Exemplo n.º 2
0
 private <T> Cursor<T> executeForCursor(SqlSession sqlSession, Object[] args) {
   Cursor<T> result;
   Object param = method.convertArgsToSqlCommandParam(args);
   if (method.hasRowBounds()) {
     RowBounds rowBounds = method.extractRowBounds(args);
     result = sqlSession.<T>selectCursor(command.getName(), param, rowBounds);
   } else {
     result = sqlSession.<T>selectCursor(command.getName(), param);
   }
   return result;
 }
Exemplo n.º 3
0
 private void executeWithResultHandler(SqlSession sqlSession, Object[] args) {
   MappedStatement ms = sqlSession.getConfiguration().getMappedStatement(command.getName());
   if (void.class.equals(ms.getResultMaps().get(0).getType())) {
     throw new BindingException(
         "method "
             + command.getName()
             + " needs either a @ResultMap annotation, a @ResultType annotation,"
             + " or a resultType attribute in XML so a ResultHandler can be used as a parameter.");
   }
   Object param = method.convertArgsToSqlCommandParam(args);
   if (method.hasRowBounds()) {
     RowBounds rowBounds = method.extractRowBounds(args);
     sqlSession.select(command.getName(), param, rowBounds, method.extractResultHandler(args));
   } else {
     sqlSession.select(command.getName(), param, method.extractResultHandler(args));
   }
 }
Exemplo n.º 4
0
 private <E> Object executeForMany(SqlSession sqlSession, Object[] args) {
   List<E> result;
   Object param = method.convertArgsToSqlCommandParam(args);
   if (method.hasRowBounds()) {
     RowBounds rowBounds = method.extractRowBounds(args);
     result = sqlSession.<E>selectList(command.getName(), param, rowBounds);
   } else {
     result = sqlSession.<E>selectList(command.getName(), param);
   }
   // issue #510 Collections & arrays support
   if (!method.getReturnType().isAssignableFrom(result.getClass())) {
     if (method.getReturnType().isArray()) {
       return convertToArray(result);
     } else {
       return convertToDeclaredCollection(sqlSession.getConfiguration(), result);
     }
   }
   return result;
 }