本文整理汇总了Java中tk.mybatis.mapper.common.Mapper类的典型用法代码示例。如果您正苦于以下问题:Java Mapper类的具体用法?Java Mapper怎么用?Java Mapper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Mapper类属于tk.mybatis.mapper.common包,在下文中一共展示了Mapper类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getGrids
import tk.mybatis.mapper.common.Mapper; //导入依赖的package包/类
/**
* 数据表grid查询 It's not good enough
* @param pageIndex
* @param pageSize
* @param paramsMap 给criteria添加参数使用
* @return
*/
private Map<String, Object> getGrids(int pageIndex, int pageSize, HashMap<String, String> paramsMap) {
PageRowBounds rowBounds = new PageRowBounds(pageIndex+1, pageSize);
SqlSession sqlSession = MybatisHelper.getSqlSession();
Mapper mapper = (Mapper) sqlSession.getMapper(UUserMapper.class);
Example example = new Example(UUser.class);
Example.Criteria criteria = example.createCriteria();
/*criteria增加条件...*/
List<UUser> users = (List<UUser>) mapper.selectByExampleAndRowBounds(example, rowBounds);
/*4.构造适合miniui_grid展示的map*/
Map<String, Object> map_grid = new HashedMap();
map_grid.put("total", users.size());
map_grid.put("data", users);
return map_grid;
}
示例2: queryGridKey
import tk.mybatis.mapper.common.Mapper; //导入依赖的package包/类
@Override
public Map<String, Object> queryGridKey(int pageNum, int pageSize,
String field, String sort,
HashMap<String, String> params)
throws ClassNotFoundException, IllegalAccessException,
InstantiationException, NoSuchMethodException, InvocationTargetException {
String[] strs = params.get("key").split("_"); /*1.strs[0]:接口, strs[1]:方法*/
SqlSession sqlSession = MybatisHelper.getSqlSession(); /*2.sqlSession*/
PageRowBounds rowBounds = new PageRowBounds(pageNum, pageSize); /*3.rowBounds*/
/*
0 = {[email protected]} "rolename" -> "0001"
1 = {[email protected]} "key" -> "UUserMapper_gridUsers"
2 = {[email protected]} "username" -> "0001"
* */
/*1.Mapper*/
Class mapper_clz = Class.forName(MAPPER + strs[0]);
Mapper mapper = (Mapper) sqlSession.getMapper(mapper_clz);
/*2.Page分页操作*/
// List<Object> list = pagePojo(params, strs, mapper, pageNum, pageSize); // pojo
List<Object> list = pageMap(params, strs, mapper, pageNum, pageSize); // map
PageInfo page = new PageInfo(list);
/*4.构造适合miniui_grid展示的map*/
Map<String, Object> map_grid = new HashedMap();
map_grid.put("total", page.getTotal());
map_grid.put("data", list);
return map_grid;
}
示例3: pageMap
import tk.mybatis.mapper.common.Mapper; //导入依赖的package包/类
/**
* 2. 2)params==>pojo 属性归档, Map参数更加通用
*
* @param params 分页查询参数
* @param strs 分页查询接口,方法
* @param mapper mybatis反射dao/mapper对象
* @param pageNum
* @param pageSize
* @return
*/
private List<Object> pageMap(HashMap<String, String> params, String[] strs,
Mapper mapper, int pageNum, int pageSize)
throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
Method mapper_method = mapper.getClass().getMethod(strs[1], new Class[]{Map.class});
/*miniui page从0开始 pagehelper从1开始*/
// PageHelper.startPage(pageNum + 1, pageSize);
// mapper.selectByRowBounds()
return (List<Object>) mapper_method.invoke(mapper, params);
}
示例4: getSample
import tk.mybatis.mapper.common.Mapper; //导入依赖的package包/类
public static Mapper getSample(Class<UUser> aClass) {
SqlSession sqlSession = MybatisHelper.getSqlSession(); /*2.sqlSession*/
return (Mapper) sqlSession.getMapper(aClass);
}
示例5: getMapper
import tk.mybatis.mapper.common.Mapper; //导入依赖的package包/类
public Mapper<T> getMapper()
{
return this.mapper;
}