本文整理汇总了Java中com.baomidou.mybatisplus.mapper.Wrapper类的典型用法代码示例。如果您正苦于以下问题:Java Wrapper类的具体用法?Java Wrapper怎么用?Java Wrapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Wrapper类属于com.baomidou.mybatisplus.mapper包,在下文中一共展示了Wrapper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testConditionOrderBys
import com.baomidou.mybatisplus.mapper.Wrapper; //导入依赖的package包/类
/**
* 测试 Condition orderBy
*/
@Test
public void testConditionOrderBys() {
//空集合测试
List<String> orders = null;
Wrapper wrapper = Condition.create();
wrapper.orderAsc(orders);
Assert.assertNull(wrapper.getSqlSegment());
orders = new ArrayList<>(3);
wrapper.orderAsc(orders);
Assert.assertNull(wrapper.getSqlSegment());
orders.add("id1");
orders.add("id2");
orders.add("id3");
wrapper.orderAsc(orders);
Assert.assertEquals("ORDER BY id1 ASC, id2 ASC, id3 ASC", wrapper.getSqlSegment());
wrapper.orderDesc(orders);
Assert.assertEquals("ORDER BY id1 ASC, id2 ASC, id3 ASC, id1 DESC, id2 DESC, id3 DESC", wrapper.getSqlSegment());
}
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:22,代码来源:EntityWrapperTest.java
示例2: update
import com.baomidou.mybatisplus.mapper.Wrapper; //导入依赖的package包/类
/**
* <p>
* 执行 SQL 更新
* </p>
*
* @param wrapper
* @return
*/
@Transactional
public boolean update(Wrapper wrapper) {
Map<String, Object> map = new HashMap<>();
map.put("et", this);
map.put("ew", wrapper);
// update
return SqlHelper.retBool(sqlSession().update(sqlStatement(SqlMethod.UPDATE), map));
}
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:17,代码来源:Model.java
示例3: testConditionOrderBy
import com.baomidou.mybatisplus.mapper.Wrapper; //导入依赖的package包/类
/**
* 测试 Condition orderBy
*/
@Test
public void testConditionOrderBy() {
Wrapper wrapper = Condition.create().orderBy("id desc");
System.out.println(wrapper.getSqlSegment());
Assert.assertEquals("ORDER BY id desc", wrapper.getSqlSegment());
}
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:10,代码来源:EntityWrapperTest.java
示例4: delete
import com.baomidou.mybatisplus.mapper.Wrapper; //导入依赖的package包/类
@Transactional
public boolean delete(Wrapper wrapper) {
return retBool(baseMapper.delete(wrapper));
}
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:5,代码来源:ServiceImpl.java
示例5: update
import com.baomidou.mybatisplus.mapper.Wrapper; //导入依赖的package包/类
@Transactional
public boolean update(T entity, Wrapper wrapper) {
return retBool(baseMapper.update(entity, wrapper));
}
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:5,代码来源:ServiceImpl.java
示例6: selectOne
import com.baomidou.mybatisplus.mapper.Wrapper; //导入依赖的package包/类
public T selectOne(Wrapper wrapper) {
return SqlHelper.getObject(baseMapper.selectList(wrapper));
}
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:4,代码来源:ServiceImpl.java
示例7: selectMap
import com.baomidou.mybatisplus.mapper.Wrapper; //导入依赖的package包/类
public Map<String, Object> selectMap(Wrapper wrapper) {
return SqlHelper.getObject(baseMapper.selectMaps(wrapper));
}
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:4,代码来源:ServiceImpl.java
示例8: selectObj
import com.baomidou.mybatisplus.mapper.Wrapper; //导入依赖的package包/类
public Object selectObj(Wrapper wrapper) {
return SqlHelper.getObject(baseMapper.selectObjs(wrapper));
}
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:4,代码来源:ServiceImpl.java
示例9: selectCount
import com.baomidou.mybatisplus.mapper.Wrapper; //导入依赖的package包/类
public int selectCount(Wrapper wrapper) {
return SqlHelper.retCount(baseMapper.selectCount(wrapper));
}
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:4,代码来源:ServiceImpl.java
示例10: selectList
import com.baomidou.mybatisplus.mapper.Wrapper; //导入依赖的package包/类
public List<T> selectList(Wrapper wrapper) {
return baseMapper.selectList(wrapper);
}
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:4,代码来源:ServiceImpl.java
示例11: selectMaps
import com.baomidou.mybatisplus.mapper.Wrapper; //导入依赖的package包/类
public List<Map<String, Object>> selectMaps(Wrapper wrapper) {
return baseMapper.selectMaps(wrapper);
}
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:4,代码来源:ServiceImpl.java
示例12: selectObjs
import com.baomidou.mybatisplus.mapper.Wrapper; //导入依赖的package包/类
public List<Object> selectObjs(Wrapper wrapper) {
return baseMapper.selectObjs(wrapper);
}
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:4,代码来源:ServiceImpl.java
示例13: selectMapsPage
import com.baomidou.mybatisplus.mapper.Wrapper; //导入依赖的package包/类
@SuppressWarnings({"rawtypes", "unchecked"})
public Page<Map<String, Object>> selectMapsPage(Page page, Wrapper wrapper) {
SqlHelper.fillWrapper(page, wrapper);
page.setRecords(baseMapper.selectMapsPage(page, wrapper));
return page;
}
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:7,代码来源:ServiceImpl.java
示例14: selectPage
import com.baomidou.mybatisplus.mapper.Wrapper; //导入依赖的package包/类
public Page<T> selectPage(Page<T> page, Wrapper wrapper) {
SqlHelper.fillWrapper(page, wrapper);
page.setRecords(baseMapper.selectPage(page, wrapper));
return page;
}
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:6,代码来源:ServiceImpl.java
示例15: deleteByEntity
import com.baomidou.mybatisplus.mapper.Wrapper; //导入依赖的package包/类
/**
* @param t
* @return
*/
@Transactional
public Integer deleteByEntity(T t) {
Wrapper<T> wrapper = new EntityWrapper<T>(t);
return mapper.delete(wrapper);
}
开发者ID:iBase4J,项目名称:iBase4J-Common,代码行数:10,代码来源:BaseService.java
示例16: deleteByEntity
import com.baomidou.mybatisplus.mapper.Wrapper; //导入依赖的package包/类
@Transactional
public Integer deleteByEntity(T t) {
Wrapper<T> wrapper = new EntityWrapper<T>(t);
return mapper.delete(wrapper);
}
开发者ID:guokezheng,项目名称:automat,代码行数:6,代码来源:BaseService.java
示例17: selectList
import com.baomidou.mybatisplus.mapper.Wrapper; //导入依赖的package包/类
public List<T> selectList(Wrapper<T> entity) {
return mapper.selectList(entity);
}
开发者ID:guokezheng,项目名称:automat,代码行数:4,代码来源:BaseService.java
示例18: getRolesByUserId
import com.baomidou.mybatisplus.mapper.Wrapper; //导入依赖的package包/类
public List<SysUserRole> getRolesByUserId(Long userId) {
SysUserRole sysUserRole = new SysUserRole(userId, null);
Wrapper<SysUserRole> wrapper = new EntityWrapper<SysUserRole>(sysUserRole);
List<SysUserRole> userRoles = sysUserRoleMapper.selectList(wrapper);
return userRoles;
}
开发者ID:guokezheng,项目名称:automat,代码行数:7,代码来源:SysAuthorizeService.java
示例19: selectOne
import com.baomidou.mybatisplus.mapper.Wrapper; //导入依赖的package包/类
/**
* 查询符合条件的第一条数据
*
* @param entity 查询条件
*/
public T selectOne(Wrapper<T> entity) {
List<T> list = mapper.selectList(entity);
if (list.size() == 0) return null;
return list.get(0);
}
开发者ID:liuxx001,项目名称:bird-java,代码行数:11,代码来源:AbstractServiceImpl.java
示例20: testGlobalConfig
import com.baomidou.mybatisplus.mapper.Wrapper; //导入依赖的package包/类
/**
* 全局配置测试
*/
@org.junit.Test
public void testGlobalConfig() {
SqlSession session = this.sqlSessionFactory().openSession(false);
TestMapper testMapper = session.getMapper(TestMapper.class);
/*Wrapper type = Condition.instance().eq("id",1).or().in("type", new Object[]{1, 2, 3, 4, 5, 6});
List list = testMapper.selectList(type);
System.out.println(list.toString());*/
Test test = new Test();
test.setCreateTime(new Date());
// 开启全局校验字符串会忽略空字符串
test.setType("");
testMapper.insert(test);
SqlSession sqlSession = this.sqlSessionFactory().openSession(false);
NotPKMapper pkMapper = sqlSession.getMapper(NotPKMapper.class);
NotPK notPK = new NotPK();
notPK.setUuid(UUID.randomUUID().toString());
notPK.setIs(true);
notPK.setIsis(false);
int num = pkMapper.insert(notPK);
Assert.assertTrue(num > 0);
NotPK notPK1 = pkMapper.selectOne(notPK);
Assert.assertNotNull(notPK1);
List<NotPK> notPKS = pkMapper.selectPage(RowBounds.DEFAULT, new EntityWrapper<>(notPK));
System.out.println(notPKS);
Wrapper type = Condition.create().eq("type", 12121212);
Assert.assertFalse(type.isEmptyOfWhere());
System.out.println(type.getSqlSegment());
Assert.assertFalse(type.isEmptyOfWhere());
pkMapper.selectPage(RowBounds.DEFAULT, type);
NotPK notPK2 = null;
try {
notPK2 = pkMapper.selectById("1");
} catch (Exception e) {
System.out.println("因为没有主键,所以没有注入该方法");
}
Assert.assertNull(notPK2);
int count = pkMapper.selectCount(Condition.EMPTY);
pkMapper.selectList(Condition.create().orderBy("uuid"));
pkMapper.selectList(Condition.create().eq("uuid", "uuid").orderBy("uuid"));
Assert.assertTrue(count > 0);
int deleteCount = pkMapper.delete(null);
Assert.assertTrue(deleteCount > 0);
List<String> list = new ArrayList<>();
list.add("1");
list.add("2");
list.add("3");
RoleMapper mapper = sqlSession.getMapper(RoleMapper.class);
System.out.println(mapper.selectBatchIds(list));
System.out.println(mapper.selectBatchIds(new HashSet<>(list)));
sqlSession.commit();
}
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:56,代码来源:GlobalConfigurationTest.java
注:本文中的com.baomidou.mybatisplus.mapper.Wrapper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论