本文整理汇总了Java中tk.mybatis.mapper.entity.Example类的典型用法代码示例。如果您正苦于以下问题:Java Example类的具体用法?Java Example怎么用?Java Example使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Example类属于tk.mybatis.mapper.entity包,在下文中一共展示了Example类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: main
import tk.mybatis.mapper.entity.Example; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
SqlSession sqlSession = MybatisHelper.getSqlSession();
CountryMapper countryMapper = sqlSession.getMapper(CountryMapper.class);
/*rowBounds*/
RowBounds rowBounds = new RowBounds(2, 5);
/*Example*/
Example example = new Example(Country.class);
Example.Criteria criteria = example.createCriteria();
// criteria.andCountrycodeBetween("0", "ZZZZZZZZZZ");
// criteria.andIdBetween(0, 20);
List<Country> countries1 = countryMapper.selectByExample(example);
log.debug("countries1" + countries1.size());
List<Country> countries2 = countryMapper.selectByExampleAndRowBounds(example, rowBounds);
log.debug("countries2" + countries2.size());
PageInfo<Country> pageInfo = new PageInfo<>(countries1);
System.out.println("PageHelperTest.main() pageInfo :" + pageInfo.getSize());
}
开发者ID:MiniPa,项目名称:cjs_ssms,代码行数:25,代码来源:PageHelperTest.java
示例17: test
import tk.mybatis.mapper.entity.Example; //导入依赖的package包/类
@Test
public void test(){
SqlSession sqlSession = MybatisHelper.getSqlSession();
CountryMapper countryMapper = sqlSession.getMapper(CountryMapper.class);
Example example = new Example(Country.class);
example.createCriteria().andGreaterThan("id",100);
PageHelper.startPage(2,10);
/*SELECT Id,countryname,countrycode FROM country WHERE ( Id > ? )*/
List<Country> countries = countryMapper.selectByExample(example);
PageInfo<Country> pageInfo = new PageInfo<Country>(countries);
System.out.println(pageInfo.getTotal());
countries = countryMapper.selectByExample(example);
pageInfo = new PageInfo<Country>(countries);
System.out.println(pageInfo.getTotal());
}
开发者ID:MiniPa,项目名称:cjs_ssms,代码行数:22,代码来源:PageMapperTest.java
示例18: testExampleBuilder
import tk.mybatis.mapper.entity.Example; //导入依赖的package包/类
@Test
public void testExampleBuilder() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
try {
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
Example example = Example.builder(Country.class).build();
List<Country> countries = mapper.selectByExample(example);
Assert.assertEquals(183, countries.size());
// 下面的查询会有缓存
Example example0 = Example.builder(Country.class)
.select().build();
List<Country> countries0 = mapper.selectByExample(example0);
Assert.assertEquals(183, countries0.size());
} finally {
sqlSession.close();
}
}
开发者ID:abel533,项目名称:Mapper,代码行数:19,代码来源:TestExampleBuilder.java
示例19: testDistinct
import tk.mybatis.mapper.entity.Example; //导入依赖的package包/类
@Test
public void testDistinct() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
try {
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
Example example = Example.builder(Country.class)
.distinct()
.build();
List<Country> countries = mapper.selectByExample(example);
Assert.assertEquals(183, countries.size());
// distinct和order by冲突问题
Example example0 = Example.builder(Country.class)
.selectDistinct("id", "countryname").build();
List<Country> countries0 = mapper.selectByExample(example0);
Assert.assertEquals(183, countries0.size());
} finally {
sqlSession.close();
}
}
开发者ID:abel533,项目名称:Mapper,代码行数:21,代码来源:TestExampleBuilder.java
示例20: testForUpdate
import tk.mybatis.mapper.entity.Example; //导入依赖的package包/类
@Test
public void testForUpdate() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
try {
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
Example example = Example.builder(Country.class)
.select("countryname")
.where(Sqls.custom().andGreaterThan("id", 100))
.orderByAsc("countrycode")
.forUpdate()
.build();
List<Country> countries = mapper.selectByExample(example);
Assert.assertEquals(83, countries.size());
} finally {
sqlSession.close();
}
}
开发者ID:abel533,项目名称:Mapper,代码行数:18,代码来源:TestExampleBuilder.java
注:本文中的tk.mybatis.mapper.entity.Example类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论