您当前的位置: 首页 >  sql

wespten

暂无认证

  • 1浏览

    0关注

    899博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Mybtais使用注解配置sql映射器

wespten 发布时间:2018-08-20 00:34:13 ,浏览量:1

注解不支持所有的功能一般开发使用xml配置文件

查询直接返回Student 直接用@select

public interface StudentMapper {

	@Insert("insert into t_student values(null,#{name},#{age})")
	public int insertStudent(Student student);
	
	@Update("update t_student set name=#{name},age=#{age} where id=#{id}")
	public int updateStudent(Student student);
	
	@Delete("delete from t_student where id=#{id}")
	public int deleteStudent(int id);
	
	@Select("select * from t_student where id=#{id}")
	public Student getStudentById(Integer id);
}

返回集合

	@Select("select * from t_student")
	@Results(
			{
				@Result(id=true,column="id",property="id"),
				@Result(column="name",property="name"),
				@Result(column="age",property="age")
			}
	)
	public List findStudents();
关注
打赏
1665965058
查看更多评论
立即登录/注册

微信扫码登录

0.0393s