Mybatis使用注解进行增删改查
2024-09-04 14:23:16
// 增
public interface StudentMapper{
@Insert("insert into student (stud_id, name, email, addr_id, phone)values(#{studId},#{name},#{email},#{address.addrId},#{phone})")
int insertStudent(Student student);
}
public interface StudentMapper{
@Insert("insert into student (name,email,addr_id,phone)values(#{name},#{email},#{address.addrId},#{phone})")
@Options(useGeneratedKeys=true,keyProperty="studId")
int insertStudent(Student student);
}
public interface StudentMapper{
@Insert("insert into student (name,email,addr_id,phone)values(#{name},#{email},#{address.addrId},#{phone})")
@SelectKey(statement="select stud_id_seq.nextval from dual",keyProperty="studId",resultType=int.calss,before=true)
int insertStudent(Student student);
}
// 改
@Update("update students set name=#{name},email=#{email}")
int updateStudent(Student student);
// 删
@Delete("delete form students where stud_id=#{studId}")
int deleteStudent(int studId)
// 查
@Select("select name,email,phone from students where stud_id=#{studId}")
Student findStudentById(Integer studId);
推荐使用xml文件进行配置,方面后续修改容易
最新文章
- ImageView属性
- laravel中的错误与日志
- [充电]C++ string字符串替换
- GIS开源软件大全
- 【bzoj1027】合金
- android如何播放资源文件夹raw中的视频
- JAVA 一个特殊的类 Object
- [原]Water Water Search Problems&;#39; Set~Orz【updating...】
- vs2010 调试C++程序 快捷键
- linux文件权限位SUID,SGID,sticky的设置理解
- android使用adb installapk出现can't find **.apk to install
- 利用Keil u4调试,精确实现软件延时
- 如何成为CSDN博客专家
- 如何检测被锁住的Oracle存储过程及处理办法汇总(转)
- css ie6最小高度问题
- SpringMVC 教程 - Handler Method
- 怎样用命令行开启或关闭Windows服务
- (链表) leetcode 21. Merge Two Sorted Lists
- [学习笔记]Java作用域变量申明和C、C++的差异性
- VC下加载JPG/GIF/PNG图片的两种方法