Browse Source

升级 1.4.1 优化查询

青苗 9 years ago
parent
commit
0fd38ce118

+ 1 - 1
mybatis-plus/pom.xml

@@ -3,7 +3,7 @@
 	<modelVersion>4.0.0</modelVersion>
 	<groupId>com.baomidou</groupId>
 	<artifactId>mybatis-plus</artifactId>
-	<version>1.4.0</version>
+	<version>1.4.1</version>
 	<packaging>jar</packaging>
 
 	<name>mybatis-plus</name>

+ 6 - 7
mybatis-plus/src/main/java/com/baomidou/framework/service/IService.java

@@ -18,7 +18,6 @@ package com.baomidou.framework.service;
 import java.util.List;
 import java.util.Map;
 
-import com.baomidou.mybatisplus.mapper.Condition;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.baomidou.mybatisplus.plugins.Page;
 
@@ -228,11 +227,11 @@ public interface IService<T, I> {
 	 * 查询列表
 	 * </p>
 	 *
-	 * @param condition
-	 *            SQL 查询条件,详见Condition类 {@link Condition}
+	 * @param entityWrapper
+	 *            实体包装类 {@link EntityWrapper}
 	 * @return
 	 */
-	List<T> selectList(Condition<T> condition);
+	List<T> selectList(EntityWrapper<T> entityWrapper);
 
 	/**
 	 * <p>
@@ -241,10 +240,10 @@ public interface IService<T, I> {
 	 * 
 	 * @param page
 	 *            翻页对象
-	 * @param condition
-	 *            SQL 查询条件,详见Condition类 {@link Condition}
+	 * @param entityWrapper
+	 *            实体包装类 {@link EntityWrapper}
 	 * @return
 	 */
-	Page<T> selectPage(Page<T> page, Condition<T> condition);
+	Page<T> selectPage(Page<T> page, EntityWrapper<T> entityWrapper);
 
 }

+ 5 - 7
mybatis-plus/src/main/java/com/baomidou/framework/service/impl/ServiceImpl.java

@@ -18,7 +18,6 @@ package com.baomidou.framework.service.impl;
 import java.util.List;
 import java.util.Map;
 
-import com.baomidou.mybatisplus.mapper.Condition;
 import org.springframework.beans.factory.annotation.Autowired;
 
 import com.baomidou.framework.service.IService;
@@ -118,14 +117,13 @@ public class ServiceImpl<M extends BaseMapper<T, I>, T, I> implements IService<T
 		return baseMapper.selectCount(entity);
 	}
 
-	public List<T> selectList(Condition<T> condition) {
-		return baseMapper.selectList(condition.getEntityWrapper());
+	public List<T> selectList(EntityWrapper<T> entityWrapper) {
+		return baseMapper.selectList(entityWrapper);
 	}
 
-	public Page<T> selectPage(Page<T> page, Condition<T> condition) {
-		condition.setOrderByField(page.getOrderByField());
-		condition.setAsc(page.isAsc());
-		page.setRecords(baseMapper.selectPage(page, condition.getEntityWrapper()));
+	public Page<T> selectPage(Page<T> page, EntityWrapper<T> entityWrapper) {
+		entityWrapper.addFilter(" ORDER BY {0} {1}", page.getOrderByField(), page.isAsc() ? "" : "DESC");
+		page.setRecords(baseMapper.selectPage(page, entityWrapper));
 		return page;
 	}
 

+ 1 - 1
mybatis-plus/src/main/java/com/baomidou/mybatisplus/MybatisConfiguration.java

@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2011-2014, hubin (jobob@qq.com).
+ * Copyright (c) 2011-2020, hubin (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  * use this file except in compliance with the License. You may obtain a copy of

+ 0 - 131
mybatis-plus/src/main/java/com/baomidou/mybatisplus/mapper/Condition.java

@@ -1,131 +0,0 @@
-/**
- * Copyright (c) 2011-2014, hubin (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.mapper;
-
-import com.baomidou.mybatisplus.toolkit.StringUtils;
-
-/**
- * 查询条件
- *
- * @author hubin
- * @Date 2016-08-18
- */
-public class Condition<T> {
-    /**
-     * 根据实体类查询
-     */
-    private T whereEntity = null;
-    /**
-     * 需要查询的参数
-     */
-    private String sqlSelect = null;
-    /**
-     * 附加Sql片段,实现自定义查询
-     */
-    private String sqlSegment = null;
-    /**
-     * <p>
-     * SQL 排序 ORDER BY 字段,例如: id DESC(根据id倒序查询)
-     * </p>
-     * <p>
-     * DESC 表示按倒序排序(即:从大到小排序)<br>
-     * ASC 表示按正序排序(即:从小到大排序)
-     * </p>
-     */
-    private String orderByField = null;
-    /**
-     * 是否为升序 ASC( 默认: true )
-     */
-    private boolean isAsc = true;
-    /**
-     * 封装EntityWrapper
-     */
-    private EntityWrapper<T> entityWrapper = null;
-
-    public T getWhereEntity() {
-        return whereEntity;
-    }
-
-    public void setWhereEntity(T whereEntity) {
-        this.whereEntity = whereEntity;
-    }
-
-    public String getSqlSelect() {
-        return sqlSelect;
-    }
-
-    public void setSqlSelect(String sqlSelect) {
-        if (StringUtils.isNotEmpty(sqlSelect)) {
-            this.sqlSelect = sqlSelect;
-        }
-    }
-
-    public String getSqlSegment() {
-        return sqlSegment;
-    }
-
-    public void setSqlSegment(String sqlSegment) {
-        if (StringUtils.isNotEmpty(sqlSegment)) {
-            this.sqlSegment = sqlSegment;
-        }
-    }
-
-    public String getOrderByField() {
-        return orderByField;
-    }
-
-    public void setOrderByField(String orderByField) {
-        if (StringUtils.isNotEmpty(orderByField)) {
-            this.orderByField = orderByField;
-        }
-    }
-
-    public boolean isAsc() {
-        return isAsc;
-    }
-
-    public void setAsc(boolean asc) {
-        isAsc = asc;
-    }
-
-    public EntityWrapper<T> getEntityWrapper() {
-        return new EntityWrapper<T>(whereEntity, sqlSelect, convertSqlSegment(sqlSegment, orderByField, isAsc));
-    }
-
-    public void setEntityWrapper(EntityWrapper<T> entityWrapper) {
-        this.entityWrapper = entityWrapper;
-    }
-
-    /**
-     * 转换 SQL 片段 + 排序
-     */
-    private String convertSqlSegment(String sqlSegment, String orderByField, boolean isAsc) {
-        StringBuffer segment = new StringBuffer();
-        if (StringUtils.isNotEmpty(sqlSegment)) {
-            segment.append(sqlSegment);
-        } else {
-            segment.append(" 1=1 ");
-        }
-        if (StringUtils.isNotEmpty(orderByField)) {
-            segment.append(" ORDER BY ").append(orderByField);
-            if (!isAsc) {
-                segment.append(" DESC");
-            }
-        }
-        return segment.toString();
-    }
-
-}

+ 77 - 21
mybatis-plus/src/main/java/com/baomidou/mybatisplus/mapper/EntityWrapper.java

@@ -15,6 +15,8 @@
  */
 package com.baomidou.mybatisplus.mapper;
 
+import java.text.MessageFormat;
+
 import com.baomidou.mybatisplus.toolkit.StringUtils;
 
 /**
@@ -38,27 +40,21 @@ public class EntityWrapper<T> {
 	private String sqlSelect = null;
 
 	/**
-	 * SQL 片段
+	 * 查询条件
 	 */
-	private String sqlSegment = null;
+	protected StringBuffer queryFilter = new StringBuffer();
 
-	protected EntityWrapper() {
-		/* 保护 */
+	public EntityWrapper() {
+		// to do nothing
 	}
 
 	public EntityWrapper(T entity) {
 		this.entity = entity;
 	}
 
-	public EntityWrapper(T entity, String sqlSegment) {
-		this.entity = entity;
-		this.sqlSegment = sqlSegment;
-	}
-
-	public EntityWrapper(T entity, String sqlSelect, String sqlSegment) {
+	public EntityWrapper(T entity, String sqlSelect) {
 		this.entity = entity;
 		this.sqlSelect = sqlSelect;
-		this.sqlSegment = sqlSegment;
 	}
 
 	public T getEntity() {
@@ -82,24 +78,84 @@ public class EntityWrapper<T> {
 		}
 	}
 
+	/**
+	 * SQL 片段
+	 */
 	public String getSqlSegment() {
-		if (StringUtils.isEmpty(sqlSegment)) {
+		/*
+		 * 无条件
+		 */
+		String tempQuery = queryFilter.toString().trim();
+		if (StringUtils.isEmpty(tempQuery)) {
 			return null;
 		}
-		StringBuffer andOr = new StringBuffer();
-		if (null == entity) {
-			andOr.append("WHERE ");
+
+		/*
+		 * 只排序、直接返回
+		 */
+		if (tempQuery.toUpperCase().indexOf("ORDER BY") == 0) {
+			return stripSqlInjection(queryFilter.toString());
+		}
+
+		/*
+		 * SQL 片段
+		 */
+		StringBuffer sqlSegment = new StringBuffer();
+		if (null == this.getEntity()) {
+			sqlSegment.append(" WHERE ");
 		} else {
-			andOr.append("AND ");
+			sqlSegment.append(" AND ");
+		}
+		sqlSegment.append(queryFilter.toString());
+		return stripSqlInjection(sqlSegment.toString());
+	}
+
+	/**
+	 * <p>
+	 * 添加查询条件
+	 * </p>
+	 * <p>
+	 * 例如: ew.addFilter("name={0}", "'123'") <br>
+	 * 输出:name='123'
+	 * </p>
+	 * 
+	 * @param filter
+	 *            SQL 片段内容
+	 * @param params
+	 *            格式参数
+	 * @return
+	 */
+	public EntityWrapper<T> addFilter(String filter, Object... params) {
+		if (StringUtils.isEmpty(filter)) {
+			return this;
 		}
-		andOr.append(sqlSegment);
-		return stripSqlInjection(andOr.toString());
+		queryFilter.append(MessageFormat.format(filter, params));
+		return this;
 	}
 
-	public void setSqlSegment(String sqlSegment) {
-		if (StringUtils.isNotEmpty(sqlSegment)) {
-			this.sqlSegment = sqlSegment;
+	/**
+	 * <p>
+	 * 添加查询条件
+	 * </p>
+	 * <p>
+	 * 例如: ew.addFilter("name={0}", "'123'").addFilterIfNeed(false,
+	 * " ORDER BY id") <br>
+	 * 输出:name='123'
+	 * </p>
+	 * 
+	 * @param willAppend
+	 *            判断条件 true 输出 SQL 片段,false 不输出
+	 * @param filter
+	 *            SQL 片段
+	 * @param params
+	 *            格式参数
+	 * @return
+	 */
+	public EntityWrapper<T> addFilterIfNeed(boolean willAppend, String filter, Object... params) {
+		if (willAppend) {
+			addFilter(filter, params);
 		}
+		return this;
 	}
 
 	/**

+ 15 - 0
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/ConfigGeneratorTest.java

@@ -1,3 +1,18 @@
+/**
+ * Copyright (c) 2011-2020, hubin (jobob@qq.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
 package com.baomidou.mybatisplus.test;
 
 import com.baomidou.mybatisplus.generator.ConfigGenerator;

+ 15 - 0
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/ContiPerfTest.java

@@ -1,3 +1,18 @@
+/**
+ * Copyright (c) 2011-2020, hubin (jobob@qq.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
 package com.baomidou.mybatisplus.test;
 
 import org.databene.contiperf.PerfTest;

+ 98 - 0
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/EntityWrapperTest.java

@@ -0,0 +1,98 @@
+/**
+ * Copyright (c) 2011-2020, hubin (jobob@qq.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR EntityWrapperS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.baomidou.mybatisplus.test;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.baomidou.mybatisplus.test.mysql.entity.User;
+
+/**
+ * <p>
+ * 条件查询测试
+ * </p>
+ * 
+ * @author hubin
+ * @date 2016-08-19
+ */
+public class EntityWrapperTest {
+
+	/*
+	 * User 查询包装器
+	 */
+	private EntityWrapper<User> ew = new EntityWrapper<User>();
+
+	@Test
+	public void test() {
+		/*
+		 * 无条件测试
+		 */
+		Assert.assertNull(ew.getSqlSegment());
+	}
+
+	@Test
+	public void test1() {
+		ew.setEntity(new User(1));
+		ew.addFilter("name={0}", "'123'").addFilterIfNeed(false, " ORDER BY id");
+		String sqlSegment = ew.getSqlSegment();
+		System.err.println(sqlSegment);
+		Assert.assertEquals(" AND name='123'", sqlSegment);
+	}
+
+	@Test
+	public void test2() {
+		ew.setEntity(new User(1));
+		ew.addFilter("name={0} order by id desc", "'123'");
+		String sqlSegment = ew.getSqlSegment();
+		System.err.println(sqlSegment);
+		Assert.assertEquals(" AND name='123' order by id desc", sqlSegment);
+	}
+
+	@Test
+	public void test3() {
+		ew.setEntity(new User(1));
+		ew.addFilter(" Order By id desc");
+		String sqlSegment = ew.getSqlSegment();
+		System.err.println(sqlSegment);
+		Assert.assertEquals(" Order By id desc", sqlSegment);
+	}
+
+	@Test
+	public void test21() {
+		ew.addFilter("name={0}", "'123'").addFilterIfNeed(false, " ORDER BY id");
+		String sqlSegment = ew.getSqlSegment();
+		System.err.println(sqlSegment);
+		Assert.assertEquals(" WHERE name='123'", sqlSegment);
+	}
+
+	@Test
+	public void test22() {
+		ew.addFilter("name={0} order by id desc", "'123'");
+		String sqlSegment = ew.getSqlSegment();
+		System.err.println(sqlSegment);
+		Assert.assertEquals(" WHERE name='123' order by id desc", sqlSegment);
+	}
+
+	@Test
+	public void test23() {
+		ew.addFilter(" Order By id desc");
+		String sqlSegment = ew.getSqlSegment();
+		System.err.println(sqlSegment);
+		Assert.assertEquals(" Order By id desc", sqlSegment);
+	}
+
+}

+ 15 - 0
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/MySqlInjector.java

@@ -1,3 +1,18 @@
+/**
+ * Copyright (c) 2011-2020, hubin (jobob@qq.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
 package com.baomidou.mybatisplus.test.mysql;
 
 import org.apache.ibatis.builder.MapperBuilderAssistant;

+ 32 - 39
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/UserMapperTest.java

@@ -41,7 +41,6 @@ import com.baomidou.mybatisplus.toolkit.IdWorker;
  */
 public class UserMapperTest {
 
-
 	/**
 	 * 
 	 * RUN 测试
@@ -53,12 +52,11 @@ public class UserMapperTest {
 	 * 2、加载sqlProvider中的SQL<br>
 	 * 3、xmlSql 与 sqlProvider不能包含相同的SQL<br>
 	 * <br>
-	 * 调整后的SQL优先级:xmlSql > sqlProvider > crudSql
-	 * <br>
+	 * 调整后的SQL优先级:xmlSql > sqlProvider > crudSql <br>
 	 */
-	public static void main( String[] args ) {
+	public static void main(String[] args) {
 
-		//加载配置文件
+		// 加载配置文件
 		InputStream in = UserMapperTest.class.getClassLoader().getResourceAsStream("mysql-config.xml");
 
 		/*
@@ -66,14 +64,12 @@ public class UserMapperTest {
 		 * SqlSessionFactory,目的是引入AutoMapper功能
 		 */
 		MybatisSessionFactoryBuilder mf = new MybatisSessionFactoryBuilder();
-		
+
 		/*
-		 * 1、数据库字段驼峰命名不需要任何设置
-		 * 2、当前演示是驼峰下划线混合命名
-		 * 3、如下开启,表示数据库字段使用下划线命名,该设置是全局的。
-		 *	 开启该设置实体可无 @TableId(value = "test_id") 字段映射
+		 * 1、数据库字段驼峰命名不需要任何设置 2、当前演示是驼峰下划线混合命名 3、如下开启,表示数据库字段使用下划线命名,该设置是全局的。
+		 * 开启该设置实体可无 @TableId(value = "test_id") 字段映射
 		 */
-		//mf.setDbColumnUnderline(true);
+		// mf.setDbColumnUnderline(true);
 
 		/**
 		 * 设置,自定义 SQL 注入器
@@ -85,7 +81,7 @@ public class UserMapperTest {
 		UserMapper userMapper = session.getMapper(UserMapper.class);
 		System.err.println(" debug run 查询执行 user 表数据变化! ");
 		userMapper.deleteAll();
-		
+
 		/**
 		 * 注解插件测试
 		 */
@@ -107,13 +103,13 @@ public class UserMapperTest {
 		rlt = userMapper.insert(new User(id, "abc", 18, 1));
 		System.err.println("\n--------------insert-------" + rlt);
 		sleep();
-		
+
 		rlt = userMapper.insertSelective(new User("abc", 18));
 		System.err.println("\n--------------insertSelective-------" + rlt);
 		sleep();
 
 		List<User> ul = new ArrayList<User>();
-		
+
 		/* 手动输入 ID */
 		ul.add(new User(11L, "1", 1, 0));
 		ul.add(new User(12L, "2", 2, 1));
@@ -123,14 +119,13 @@ public class UserMapperTest {
 		ul.add(new User(16L, "6", 6, 0));
 		ul.add(new User(17L, "7", 7, 0));
 		ul.add(new User(18L, "deleteByMap", 7, 0));
-		
+
 		/* 使用 ID_WORKER 自动生成 ID */
 		ul.add(new User("8", 8, 1));
 		ul.add(new User("9", 9, 1));
 		rlt = userMapper.insertBatch(ul);
 		System.err.println("\n--------------insertBatch----------------" + rlt + "\n\n");
 
-
 		/**
 		 * 删除
 		 */
@@ -155,7 +150,6 @@ public class UserMapperTest {
 		System.err.println("--------------deleteSelective------------------ result=" + rlt + "\n\n");
 		sleep();
 
-
 		/**
 		 * <p>
 		 * 修改
@@ -168,21 +162,21 @@ public class UserMapperTest {
 		rlt = userMapper.updateSelectiveById(new User(12L, "MybatisPlus"));
 		System.err.println("------------------updateSelectiveById---------------------- result=" + rlt + "\n\n");
 		sleep();
-		
+
 		rlt = userMapper.updateById(new User(12L, "update all column", 12, 12));
 		System.err.println("------------------updateById---------------------- result=" + rlt + "\n\n");
 		sleep();
-		
+
 		rlt = userMapper.update(new User("55", 55, 5), new User(15L, "5"));
 		System.err.println("------------------update---------------------- result=" + rlt + "\n\n");
 		sleep();
-		
+
 		rlt = userMapper.updateSelective(new User("00"), new User(15L, "55"));
 		System.err.println("------------------updateSelective---------------------- result=" + rlt + "\n\n");
 		sleep();
-		
+
 		/* 无条件选择更新 */
-		//userMapper.updateSelective(new User("11"), null);
+		// userMapper.updateSelective(new User("11"), null);
 
 		List<User> userList = new ArrayList<User>();
 		userList.add(new User(11L, "updateBatchById-1", 1, 1));
@@ -206,29 +200,29 @@ public class UserMapperTest {
 		idList.add(11L);
 		idList.add(12L);
 		List<User> ul0 = userMapper.selectBatchIds(idList);
-		for ( int i = 0 ; i < ul0.size() ; i++ ) {
+		for (int i = 0; i < ul0.size(); i++) {
 			print(ul0.get(i));
 		}
-		
+
 		System.err.println("\n------------------selectByMap-----满足 map 条件的数据----");
 		Map<String, Object> cm = new HashMap<String, Object>();
 		cm.put("test_type", 1);
 		List<User> ul1 = userMapper.selectByMap(cm);
-		for ( int i = 0 ; i < ul1.size() ; i++ ) {
+		for (int i = 0; i < ul1.size(); i++) {
 			print(ul1.get(i));
 		}
 
 		System.err.println("\n------------------selectOne----------------------");
 		User userOne = userMapper.selectOne(new User("abc"));
 		print(userOne);
-		
+
 		System.err.println("\n------------------selectCount----------------------");
 		System.err.println("查询 type=1 总记录数:" + userMapper.selectCount(new User(1)));
 		System.err.println("总记录数:" + userMapper.selectCount(null));
 
 		System.err.println("\n------------------selectList-----所有数据----id--DESC--排序----");
-		List<User> ul2 = userMapper.selectList(new EntityWrapper<User>(null, " 1=1 ORDER BY id DESC"));
-		for ( int i = 0 ; i < ul2.size() ; i++ ) {
+		List<User> ul2 = userMapper.selectList(new EntityWrapper<User>(null, "age,name"));
+		for (int i = 0; i < ul2.size(); i++) {
 			print(ul2.get(i));
 		}
 
@@ -249,26 +243,27 @@ public class UserMapperTest {
 		/*
 		 * 查询条件,SQL 片段( 注意!程序会自动在 sqlSegmet 内容前面添加 where 或者 and )
 		 */
-		ew.setSqlSegment("name like '%dateBatch%'");
+		ew.addFilter("name like {0}", "'%dateBatch%'");
+		ew.addFilter(" ORDER BY {0} {1}", page.getOrderByField(), page.isAsc() ? "" : "DESC");
 		List<User> paginList = userMapper.selectPage(page, ew);
 		page.setRecords(paginList);
-		for ( int i = 0 ; i < page.getRecords().size() ; i++ ) {
+		for (int i = 0; i < page.getRecords().size(); i++) {
 			print(page.getRecords().get(i));
 		}
 		System.err.println(" 翻页:" + page.toString());
 
 		System.err.println("\n---------------xml---selectListRow 分页查询,不查询总数(此时可自定义 count 查询)----无查询条件--------------");
-		//TODO 查询总数传 Page 对象即可
+		// TODO 查询总数传 Page 对象即可
 		List<User> rowList = userMapper.selectListRow(new Pagination(0, 2, false));
-		for ( int i = 0 ; i < rowList.size() ; i++ ) {
+		for (int i = 0; i < rowList.size(); i++) {
 			print(rowList.get(i));
 		}
-		
+
 		/*
 		 * 用户列表
 		 */
-		paginList = userMapper.selectList(new EntityWrapper<User>(null, null, null));
-		for ( int i = 0 ; i < rowList.size() ; i++ ) {
+		paginList = userMapper.selectList(new EntityWrapper<User>());
+		for (int i = 0; i < rowList.size(); i++) {
 			print(rowList.get(i));
 		}
 
@@ -284,7 +279,6 @@ public class UserMapperTest {
 		session.commit();
 	}
 
-
 	/*
 	 * 打印测试信息
 	 */
@@ -298,14 +292,13 @@ public class UserMapperTest {
 		}
 	}
 
-
 	/*
-	 * 慢点打印 
+	 * 慢点打印
 	 */
 	private static void sleep() {
 		try {
 			Thread.sleep(1000);
-		} catch ( InterruptedException e ) {
+		} catch (InterruptedException e) {
 			e.printStackTrace();
 		}
 	}