> 一、开启AR模式—实体类必须继承Model类
> 二、AR的增删改查操作
1、插入操作insert()
**
*AR插入操作*/
@Test
public voidtestARInsert( i
Employee employee = new Employee();
employee.setLastName("宋老师");
employee.setEmail( "s1s@atguigu.com" );
employee.setGender(1);
employee.setAge(35);
boolean result = employee.insert();
system.out.print1n( "result: " +result );
}
2、修改操作updateById()
/**
*AR修改操作*/
@Test
public void testARUpdate() {
Employee employee = new Employee();
employee.setid( 14);
employee.setLastName("宋老湿");
employee.setEmail("s1s@atguigu.com" ) ;
employee.setGender(1);
employee.setAge(36);
boolean result = employee.updateById();
system.out.print1n("result:" +result );
}
3、查询操作
/*AR查询操作*/
@Test
public void testARSeiect(
//selectById();
Employee employee = new Employee();
employee.setId(14);
Employee result = employee.selectById();
System.out.printin(result );
//selectAll();
List<Employee> emps_ = employee.selectA11();
system.out.print1n(emps);
//selectList();
List<Employee> emps=employee.selectList(new Entitywrapper<Employee>().like("last_name"""老师"));
system.out.print1n(emps);
//selectCount();
Integer result = employee.selectCount(new Entitywrapper<Employee>().eq("gender" , 0));
system.out.print1n("result: " +result );
}
4、删除操作
@Test
public void testARDelete(){
//deleteById();
Employee employee = new Employee();
boolean result = employee.deleteById(2);
employee.setId(2);
boolean result = employee.deleteById();
system.out.print1n( "result: " +result );
//delete()方法删除
//删除不存在的数据,逻辑上也是属于成功的
boolean result = employee.delete(new Entitywrapper<Employee>().1ike("last_name","小"));
system.out.print1n(result );
}