标签:use lse ESS public limit owb 使用 sele parameter
使用limita分页
select * from t_user limit startIndex,pageSize;
接口
List<User> getUserLimit(Map<String,Integer> map);
mapper.xml
<select id="getUserLimit" parameterType="map" resultMap="UserMap" >
select * from t_user limit #{startIndex},#{pageSize}
</select>
测试
public void getUserLimit(){
SqlSession sqlSession = MybatisUtils.getSqlSession();
UserMapper mapper = sqlSession.getMapper(UserMapper.class);
Map<String,Integer> map = new HashMap<String, Integer>();
map.put("startIndex",0);
map.put("pageSize",2);
List<User> userList = mapper.getUserLimit(map);
for (User user : userList) {
System.out.println(user);
}
sqlSession.close();
}
接口
List<User> getUserByRowBounds();
mapper.xml
<select id="getUserByRowBounds" resultMap="UserMap" >
select * from t_user
</select>
测试
public void getUserByRowBounds(){
SqlSession sqlSession = MybatisUtils.getSqlSession();
RowBounds rowBounds = new RowBounds(0,3);
List<User> User = sqlSession.selectList("com.believe.mapper.UserMapper.getUserByRowBounds",null,rowBounds);
for (User user : User) {
System.out.println(user);
}
sqlSession.close();
}
标签:use lse ESS public limit owb 使用 sele parameter
原文地址:https://www.cnblogs.com/thetree/p/07_mybatis.html