public interface StudentMapper {
@Insert("insert into student(name,credit_hour) value(#{name},#{creditHour})")
@Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")//加入该注解可以保持对象后,查看对象插入id
public int insert(Student s);
}
@Service
public class StudentService {
@Resource
private StudentMapper mStudentMapper;
public int insert(Student s){
mStudentMapper.insert(s);
return s.getId();
}
}