private SqlSource getSqlSource(
     MappedStatement ms, SqlSource sqlSource, Object parameterObject, boolean isCount) {
   if (ms.getSqlSource() instanceof DynamicSqlSource) {
     MetaObject msObject = MetaObjectUtils.forObject(ms);
     SqlNode sqlNode = (SqlNode) msObject.getValue("sqlSource.rootSqlNode");
     MixedSqlNode mixedSqlNode = null;
     if (sqlNode instanceof MixedSqlNode) {
       mixedSqlNode = (MixedSqlNode) sqlNode;
     } else {
       List<SqlNode> contents = new ArrayList<SqlNode>(1);
       contents.add(sqlNode);
       mixedSqlNode = new MixedSqlNode(contents);
     }
     return new CustomerDynamicSqlSource(ms.getConfiguration(), mixedSqlNode, isCount, dialect);
   } else if (sqlSource instanceof ProviderSqlSource) {
     return new CustomerProviderSqlSource(
         ms.getConfiguration(), (ProviderSqlSource) sqlSource, isCount, dialect);
   } else if (!isCount) {
     BoundSql boundSql = sqlSource.getBoundSql(parameterObject);
     return new StaticSqlSource(
         ms.getConfiguration(),
         dialect.generatePageSQL(boundSql.getSql()),
         MybatisUtils.plusTwoParameterToMapping(ms.getConfiguration(), boundSql));
   } else {
     BoundSql boundSql = sqlSource.getBoundSql(parameterObject);
     return new StaticSqlSource(
         ms.getConfiguration(),
         dialect.generateCountSQL(boundSql.getSql()),
         boundSql.getParameterMappings());
   }
 }
 public Map setParameter(
     MappedStatement ms, Object parameterObject, PageParam page, Dialect dialect) {
   BoundSql boundSql = ms.getBoundSql(parameterObject);
   Map paramMap = null;
   if (parameterObject == null) {
     paramMap = new HashMap();
   } else if (parameterObject instanceof Map) {
     paramMap = (Map) parameterObject;
   } else {
     paramMap = new HashMap();
     boolean hasTypeHandler =
         ms.getConfiguration().getTypeHandlerRegistry().hasTypeHandler(parameterObject.getClass());
     MetaObject metaObject = MetaObjectUtils.forObject(parameterObject);
     if (ms.getSqlSource() instanceof CustomerProviderSqlSource) {
       paramMap.put(Const.PROVIDER_OBJECT, parameterObject);
     }
     if (!hasTypeHandler) {
       for (String name : metaObject.getGetterNames()) {
         paramMap.put(name, metaObject.getValue(name));
       }
     }
     if (boundSql.getParameterMappings() != null && boundSql.getParameterMappings().size() > 0) {
       for (ParameterMapping parameterMapping : boundSql.getParameterMappings()) {
         String name = parameterMapping.getProperty();
         if (!name.equals(Const.PARAMETER_FIRST)
             && !name.equals(Const.PARAMETER_SECOND)
             && paramMap.get(name) == null) {
           if (hasTypeHandler
               || parameterMapping.getJavaType().equals(parameterObject.getClass())) {
             paramMap.put(name, parameterObject);
             break;
           }
         }
       }
     }
   }
   // 备份原始参数对象
   paramMap.put(Const.ORIGINAL_PARAMETER_OBJECT, parameterObject);
   // 设置分页参数
   Map<String, Object> customerPageParams = dialect.getPageParameter(page);
   if (customerPageParams != null) {
     for (String key : customerPageParams.keySet()) {
       paramMap.put(key, customerPageParams.get(key));
     }
   }
   return paramMap;
 }