注解不支持所有的功能一般开发使用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"),