当前位置: 首页>>代码示例>>Java>>正文


Java Example类代码示例

本文整理汇总了Java中tk.mybatis.mapper.entity.Example的典型用法代码示例。如果您正苦于以下问题:Java Example类的具体用法?Java Example怎么用?Java Example使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Example类属于tk.mybatis.mapper.entity包,在下文中一共展示了Example类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testDeleteByExample2

import tk.mybatis.mapper.entity.Example; //导入依赖的package包/类
@Test
public void testDeleteByExample2() {
    SqlSession sqlSession = MybatisHelper.getSqlSession();
    try {
        CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
        Example example = new Example(Country.class);
        example.createCriteria().andLike("countryname", "A%");
        example.or().andGreaterThan("id", 100);
        example.setDistinct(true);
        int count = mapper.deleteByExample(example);
        //查询总数
        Assert.assertEquals(true, count > 83);
    } finally {
        sqlSession.rollback();
        sqlSession.close();
    }
}
 
开发者ID:godlike110,项目名称:tk-mybatis,代码行数:18,代码来源:TestDeleteByExample.java

示例2: testAndExample

import tk.mybatis.mapper.entity.Example; //导入依赖的package包/类
@Test
public void testAndExample() {
    SqlSession sqlSession = MybatisHelper.getSqlSession();
    try {
        CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
        Example example = new Example(Country.class);
        example.createCriteria()
                .andCondition("countryname like 'C%' and id < 100")
                .andCondition("length(countryname) = ", 5)
                .andCondition("countrycode =", "CN", StringTypeHandler.class);
        List<Country> countries = mapper.selectByExample(example);
        //查询总数
        Assert.assertEquals(1, countries.size());
    } finally {
        sqlSession.close();
    }
}
 
开发者ID:godlike110,项目名称:tk-mybatis,代码行数:18,代码来源:TestSelectByExample.java

示例3: testSelectCountByExample2

import tk.mybatis.mapper.entity.Example; //导入依赖的package包/类
@Test
public void testSelectCountByExample2() {
    SqlSession sqlSession = MybatisHelper.getSqlSession();
    try {
        CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
        Example example = new Example(Country.class);
        example.createCriteria().andLike("countryname", "A%");
        example.or().andGreaterThan("id", 100);
        example.setDistinct(true);
        int count = mapper.selectCountByExample(example);
        //查询总数
        Assert.assertEquals(true, count > 83);
    } finally {
        sqlSession.close();
    }
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:17,代码来源:TestSelectCountByExample.java

示例4: testSelectByExample2

import tk.mybatis.mapper.entity.Example; //导入依赖的package包/类
@Test
public void testSelectByExample2() {
    SqlSession sqlSession = MybatisHelper.getSqlSession();
    try {
        CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
        Example example = new Example(Country.class);
        example.createCriteria().andLike("countryname", "A%");
        example.or().andGreaterThan("id", 100);
        example.            setDistinct(true);
        List<Country> countries = mapper.selectByExample(example);
        //查询总数
        Assert.assertEquals(true, countries.size() > 83);
    } finally {
        sqlSession.close();
    }
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:17,代码来源:TestSelectByExample.java

示例5: testSelectByExample4

import tk.mybatis.mapper.entity.Example; //导入依赖的package包/类
@Test
public void testSelectByExample4() {
    SqlSession sqlSession = MybatisHelper.getSqlSession();
    try {
        Country ct = new Country();
        ct.setCountryname("China");

        CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
        Example example = new Example(Country.class);
        example.createCriteria().andGreaterThan("id", 20).andEqualTo(ct);
        List<Country> countries = mapper.selectByExample(example);
        //查询总数
        System.out.println(countries.get(0).toString());
        Assert.assertEquals(1, countries.size());
    } finally {
        sqlSession.close();
    }
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:19,代码来源:TestSelectByExample.java

示例6: testSelectColumnsByExample

import tk.mybatis.mapper.entity.Example; //导入依赖的package包/类
@Test
public void testSelectColumnsByExample() {
    SqlSession sqlSession = MybatisHelper.getSqlSession();
    try {
        CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
        Example example = new Example(Country.class);
        example.createCriteria().andGreaterThan("id", 100).andLessThan("id", 151);
        example.or().andLessThan("id", 41);
        example.selectProperties("id", "countryname", "hehe");
        List<Country> countries = mapper.selectByExample(example);
        //查询总数
        Assert.assertEquals(90, countries.size());
    } finally {
        sqlSession.close();
    }
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:17,代码来源:TestSelectByExample.java

示例7: testSelectByExampleForUpdate

import tk.mybatis.mapper.entity.Example; //导入依赖的package包/类
@Test
public void testSelectByExampleForUpdate() {
    SqlSession sqlSession = MybatisHelper.getSqlSession();
    try {
        CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
        Example example = new Example(Country.class);
        example.setForUpdate(true);
        example.createCriteria().andGreaterThan("id", 100).andLessThan("id",151);
        example.or().andLessThan("id", 41);
        List<Country> countries = mapper.selectByExample(example);
        //查询总数
        Assert.assertEquals(90, countries.size());
    } finally {
        sqlSession.close();
    }
}
 
开发者ID:godlike110,项目名称:tk-mybatis,代码行数:17,代码来源:TestSelectByExample.java

示例8: testSelectByExampleInNotIn

import tk.mybatis.mapper.entity.Example; //导入依赖的package包/类
@Test
public void testSelectByExampleInNotIn() {
    SqlSession sqlSession = MybatisHelper.getSqlSession();
    try {
        CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
        Example example = new Example(Country.class);
        Set<Integer> set = new HashSet<Integer>();
        set.addAll(Arrays.asList(new Integer[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}));
        example.createCriteria().andIn("id", set)
                .andNotIn("id", Arrays.asList(new Object[]{11}));
        List<Country> countries = mapper.selectByExample(example);
        //查询总数
        Assert.assertEquals(10, countries.size());
    } finally {
        sqlSession.close();
    }
}
 
开发者ID:godlike110,项目名称:tk-mybatis,代码行数:18,代码来源:TestSelectByExample.java

示例9: getCurentOffices

import tk.mybatis.mapper.entity.Example; //导入依赖的package包/类
/**
 * 获取当前用户机构信息
 * @return
 */
@PostMapping("/getofficebyuser")
@ResponseBody
public BaseResult getCurentOffices() {
    SysUser user= UserUtils.getUser();
    Example example=new Example(SysOffice.class);
    List<SysOffice> offices=new ArrayList<SysOffice>();
    if(user.isAdmin()){
        offices=service.selectAll();
    }else{
        String companyId=user.getOfficeId();
        SysOffice currentOffice= service.selectByPrimaryKey(companyId);
        if(currentOffice!=null){
           String parentIds= currentOffice.getParentIds();
            Example.Criteria criteria= example.createCriteria();
            String inCondition=parentIds.substring(0,parentIds.length()-1);
            criteria.andCondition(" id in ("+inCondition+")");
            offices=service.selectByExample(example);
        }
    }
    return new BaseResult(BaseResultCode.SUCCESS, offices);
}
 
开发者ID:egojit8,项目名称:easyweb,代码行数:26,代码来源:OfficeController.java

示例10: index

import tk.mybatis.mapper.entity.Example; //导入依赖的package包/类
/**
 * 获取所有机构列表
 * @param model
 * @return
 */
@PostMapping("/index")
@ResponseBody
public Page<SysOffice> index(HttpServletRequest request,
                       HttpServletResponse response, SysOffice model) {
    Page<SysOffice> pg = new Page<SysOffice>(request, response,-1);

    Example example = new Example(SysOffice.class);
    Example.Criteria criteria = example.createCriteria();
    if (!StringUtils.isEmpty(model.getName())) {
        criteria.andLike("name", "%" + model.getName() + "%");
    }

    if (StringUtils.isEmpty(model.getParentId())) {
        criteria.andEqualTo("parentId","0");//获取公司
    }else {
        criteria.andEqualTo("parentId",model.getParentId());
    }
    pg = service.selectPageByExample(example, pg);
    return pg;
}
 
开发者ID:egojit8,项目名称:easyweb,代码行数:26,代码来源:OfficeController.java

示例11: index

import tk.mybatis.mapper.entity.Example; //导入依赖的package包/类
@ResponseBody
@PostMapping("/index")
@ApiOperation(value = "用户管理接口")
public Page<SysUser> index(HttpServletRequest request,
                           HttpServletResponse response,SysUser user){
    Page<SysUser> pg=new Page<SysUser>(request,response);
    Example example=new Example(SysUser.class);
    Example.Criteria criteria= example.createCriteria();
    if(!StringUtils.isEmpty(user.getLoginName())) {
        criteria.andLike("loginName", "%"+user.getLoginName()+"%");
    }
    if(!StringUtils.isEmpty(user.getName())) {
        criteria.andLike("name", "%"+user.getName()+"%");
    }
    pg= userService.selectPageByExample(example,pg);
    return pg;
}
 
开发者ID:egojit8,项目名称:easyweb,代码行数:18,代码来源:UserController.java

示例12: index

import tk.mybatis.mapper.entity.Example; //导入依赖的package包/类
/**
 * 获取所有字典列表
 * @param model
 * @return
 */
@PostMapping("/index")
@ResponseBody
public Page<SysDict> index(HttpServletRequest request,
                             HttpServletResponse response, SysDict model) {
    Page<SysDict> pg = new Page<SysDict>(request, response,-1);

    Example example = new Example(SysDict.class);
    Example.Criteria criteria = example.createCriteria();
    if (!StringUtils.isEmpty(model.getLabel())) {
        criteria.andLike("label", "%" + model.getLabel() + "%");
    }
    if (StringUtils.isEmpty(model.getParentId())) {
        criteria.andEqualTo("parentId","0");//获取公司
    }else {
        criteria.andEqualTo("parentId",model.getParentId());
    }
    pg = service.selectPageByExample(example, pg);
    return pg;
}
 
开发者ID:egojit8,项目名称:easyweb,代码行数:25,代码来源:DictController.java

示例13: index

import tk.mybatis.mapper.entity.Example; //导入依赖的package包/类
/**
 * 获取所有菜单列表
 * @param model
 * @return
 */
@PostMapping("/index")
@ResponseBody
public Page<SysMenu> index(HttpServletRequest request,
                           HttpServletResponse response, SysMenu model) {
    Page<SysMenu> pg = new Page<SysMenu>(request, response,-1);

    Example example = new Example(SysMenu.class);
    Example.Criteria criteria = example.createCriteria();
    if (!StringUtils.isEmpty(model.getName())) {
        criteria.andLike("name", "%" + model.getName() + "%");
    }
    if (StringUtils.isEmpty(model.getParentId())) {
        criteria.andEqualTo("parentId","0");//获取公司
    }else {
        criteria.andEqualTo("parentId",model.getParentId());
    }
    pg = service.selectPageByExample(example, pg);
    return pg;
}
 
开发者ID:egojit8,项目名称:easyweb,代码行数:25,代码来源:MenuController.java

示例14: index

import tk.mybatis.mapper.entity.Example; //导入依赖的package包/类
/**
 * 获取所有角色列表
 * @param model
 * @return
 */
@PostMapping("/index")
@ResponseBody
public Page<SysRole> index(HttpServletRequest request,
                           HttpServletResponse response, SysRole model) {
    Page<SysRole> pg = new Page<SysRole>(request, response,-1);

    Example example = new Example(SysRole.class);
    Example.Criteria criteria = example.createCriteria();
    if (!StringUtils.isEmpty(model.getName())) {
        criteria.andLike("name", "%" + model.getName() + "%");
    }

    if (!StringUtils.isEmpty(model.getOfficeId())) {
        criteria.andEqualTo("officeId", model.getOfficeId());
    }
    pg = service.selectPageByExample(example, pg);
    return pg;
}
 
开发者ID:egojit8,项目名称:easyweb,代码行数:24,代码来源:RoleController.java

示例15: getGrids

import tk.mybatis.mapper.entity.Example; //导入依赖的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;
}
 
开发者ID:MiniPa,项目名称:cjs_ssms,代码行数:24,代码来源:SelectController.java


注:本文中的tk.mybatis.mapper.entity.Example类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。