一、mybatis.xml
  • <mapper>中使用<package/>
  二、mapper.java接口
  • public interface StudentMapper2 {
  •       @Select("select * from stu")
  •       List<Student> selAll();
  • }
  三、Test中调用
  • StudentMapper2 sm = session.getMapper(StudentMapper2.class);
  • List<Student> list = sm.selAll();
  四、多值传递(用#{param1},#{param2},#{param3}。不能用#{0},#{1},#{2}) package top.woldcn.mapper;   import java.util.List; import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Update; import top.woldcn.entity.Comment;   public interface CommentMapper {     @Insert("insert into comment values(default, #{param1},#{param2},#{param3},default)")     int insert(int essayId, int visitorId, String content); }        
扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄