mybatisplus crud

更新:

public void Testupdate() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(“ApplicationContext.xml”);
StudentMapper studentMapper = (StudentMapper)context.getBean(“studentMapper”);
Student student = new Student();
student.setStuid(1);
student.setStuname(“lan”);
student.setStuage(22);
int rows = studentMapper.updateById(student);
System.out.println(“成功更新”+rows+“条数据”);
}

删除:

where id = ?
public void Testdelete() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(“ApplicationContext.xml”);
StudentMapper studentMapper = (StudentMapper)context.getBean(“studentMapper”);
int rows = studentMapper.deleteById(1);
System.out.println(“成功更新”+rows+“条数据”);
}

where id in( ???)
public void Testdelete2() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(“ApplicationContext.xml”);
StudentMapper studentMapper = (StudentMapper)context.getBean(“studentMapper”);
List list = new ArrayList();
list.add(1);
list.add(2);
int rows = studentMapper.deleteBatchIds(list);
System.out.println(“成功更新”+rows+“条数据”);
}

where ? =?
public void Testdelete3() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(“ApplicationContext.xml”);
StudentMapper studentMapper = (StudentMapper)context.getBean(“studentMapper”);
Map<String, Object> map = new HashMap<String, Object>();
map.put(“stuname”, “chen”);
int rows = studentMapper.deleteByMap(map);
System.out.println(“成功更新”+rows+“条数据”);
}

加入

public void Testinsert() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(“ApplicationContext.xml”);
StudentMapper studentMapper = (StudentMapper)context.getBean(“studentMapper”);
Student student = new Student();
student.setStuid(99);
student.setStuname(“fish”);
student.setStuage(100);
int rows = studentMapper.insert(student);
System.out.println(“成功更新”+rows+“条数据”);
}

查询

where id = ?
public void Testselect() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(“ApplicationContext.xml”);
StudentMapper studentMapper = (StudentMapper)context.getBean(“studentMapper”);
Student student= studentMapper.selectById(1);
System.out.println(student.getStuage());
}
where id in(???)

public void Testselect2() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(“ApplicationContext.xml”);
StudentMapper studentMapper = (StudentMapper)context.getBean(“studentMapper”);
List list = new ArrayList();
list.add(1);
list.add(2);
List student = studentMapper.selectBatchIds(list);
System.out.println(student);
}
where ? =?

public void Testselect3() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(“ApplicationContext.xml”);
StudentMapper studentMapper = (StudentMapper)context.getBean(“studentMapper”);
Map<String, Object> map = new HashMap<String, Object>();
map.put(“stuname”, “chen”);
List student = studentMapper.selectByMap(map);
System.out.println(student);
}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值