code: public MappedStatement getCountMappedStatement(MappedStatement ms) {
      	
      	String newMsId = ms.getId() + PAGE_COUNT_SUFFIX;
      	
      	MappedStatement statement = null;
      	Configuration configuration = ms.getConfiguration();
  	
      	try {
      		statement = configuration.getMappedStatement(newMsId);
      		if(statement != null)return statement;
  		} catch (Exception e) {}
      	
      	synchronized (configuration) {   
      		
      		if(configuration.hasStatement(newMsId))return configuration.getMappedStatement(newMsId);
      		
      		MappedStatement.Builder builder = new MappedStatement.Builder(ms.getConfiguration(), newMsId, ms.getSqlSource(), ms.getSqlCommandType());
      		builder.resource(ms.getResource());
      		builder.fetchSize(ms.getFetchSize());
      		builder.statementType(ms.getStatementType());
      		builder.keyGenerator(ms.getKeyGenerator());
      		if (ms.getKeyProperties() != null && ms.getKeyProperties().length != 0) {
      			StringBuilder keyProperties = new StringBuilder();
      			for (String keyProperty : ms.getKeyProperties()) {
      				keyProperties.append(keyProperty).append(",");
      			}
      			keyProperties.delete(keyProperties.length() - 1, keyProperties.length());
      			builder.keyProperty(keyProperties.toString());
      		}
      		builder.timeout(ms.getTimeout());
      		builder.parameterMap(ms.getParameterMap());
      		//count查询返回值int
      		 List<ResultMap> resultMaps = new ArrayList<ResultMap>();
               String id = newMsId + "-Inline";
               ResultMap resultMap = new ResultMap.Builder(configuration, id, Long.class, new ArrayList<ResultMapping>(0)).build();
               resultMaps.add(resultMap);
               builder.resultMaps(resultMaps);
               
      		builder.resultSetType(ms.getResultSetType());
      		builder.cache(ms.getCache());
      		builder.flushCacheRequired(ms.isFlushCacheRequired());
      		builder.useCache(ms.isUseCache());
      		
      		statement = builder.build();
      		configuration.addMappedStatement(statement);
      		return statement;
      	}
      	
      }
docs: 新建count查询的MappedStatement
  
  @param ms
  @return