javaEEday09-Mybatis-基础操作-删除
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
package com.inmind.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface EmpMapper {
|
||||
//定义方法
|
||||
@Delete("delete from emp where id = #{id};")
|
||||
int delete(Integer id);//想返回删除数据的个数
|
||||
// void delete(Integer id);//不想获得删除数据的个数
|
||||
}
|
||||
|
||||
+13
@@ -1,13 +1,26 @@
|
||||
package com.inmind;
|
||||
|
||||
import com.inmind.mapper.EmpMapper;
|
||||
import org.junit.jupiter.api.AutoClose;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class SpringbootMybatisCrudApplicationTests {
|
||||
|
||||
@Autowired
|
||||
private EmpMapper empMapper;
|
||||
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDelete(){
|
||||
int deleteCount = empMapper.delete(16);
|
||||
System.out.println("删除数据的条数:"+deleteCount);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user