mybatis
weixin_46373361
学生
展开
-
mybatis六、一对多、多对一查询
多对一、一对多public interface StudentMapper { //查询所有的学生,以及对应的老师 List<Student> getStudent(); List<Student> getStudent2();}public interface TeacherMapper { List<Teacher> getTeacher(); Teacher getTeacher2(@Param("tid") int原创 2020-12-12 21:01:49 · 83 阅读 · 0 评论 -
mybatis五、注解开发sql
mybatis注解lombok插件,下面有很多方法,可以避免手动生成getter等方法。//实体类@Data//Data:无参构造,get,set,tostring,hashcode,equals@AllArgsConstructor@NoArgsConstructor@Getter@Setter@ToString@Alias("hello")//起别名public class User { private int id; private String name;原创 2020-12-12 20:57:31 · 99 阅读 · 0 评论 -
mybatis四、解决实体类与数据库字段值不匹配的问题
mybatis四解决实体类与数据库字段值不匹配的问题@Datapublic class User { private int id; private String name; private String password;}数据库中的字段password --> pwdresultMap结果集映射<?xml version="1.0" encoding="UTF8" ?><!DOCTYPE mapper PUBLIC "-原创 2020-12-12 20:47:54 · 497 阅读 · 0 评论 -
mybatis(三)
mybatis三万能map和模糊查询public interface UserMapper { //万能map int addUser2(Map<String, Object> map); User getUserById2(Map<String, Object> map1); //模糊查询 List<User> getUserLike(String value);}<?xml version="1.0" encod原创 2020-12-12 20:42:32 · 126 阅读 · 0 评论 -
mybatis(二)
mybatis二属性优化<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"><configuration> <!-- 通过properties配置environment--> <properties resource="db.properti原创 2020-12-12 20:37:15 · 78 阅读 · 0 评论