提交 ee5ee5a5 编写于 作者: Q qiurunze

提交

上级 07c30f03
......@@ -44,7 +44,7 @@
### 以下所有内容都已完成,但是因内容多需逐渐整理上传! 专题的部分也会尽快上传更新! 立个flag 半年内吧争取全部更新完!各位稍安勿躁!
### [如要提交代码请先看--提交合并代码规范](/docs/code-criterion.md)
### [如要提交代码请先看--提交合并代码规范提交者的后面都会有署名方面大家问问题](/docs/code-criterion.md)
| ID | Problem | Article |
| --- | --- | :--- |
......@@ -101,9 +101,6 @@
#### Get Start
下载项目, 切换的项目根目录
```bash
Linux/Mac:
......@@ -116,7 +113,6 @@
```
运行以上命令相关依赖便会安装完毕
启动GeekQMainApplication主类即可
若有对于./mvnw 不了解的请点击下方链接介绍
###### [maven-wrapper介绍](/docs/maven-wrapper.md)
###### [maven-wrapper介绍(add by zhangkai)](/docs/maven-wrapper.md)
......@@ -88,4 +88,10 @@
### generatorConfig.xml 内容解析?
已在其中备注,详细内容请见generatorConfig.xml
### generatorConfig.xml 内容解析?
\ No newline at end of file
### xml映射文件都会有一个dao接口,工作原理?
Dao接口里的方法,是不能重载的,因为是全限名+方法名的保存和寻找策略。
Dao接口的工作原理是JDK动态代理,Mybatis运行时会使用JDK动态代理为Dao接口生成代理proxy对象,
代理对象proxy会拦截接口方法,转而执行MappedStatement所代表的sql,然后将sql执行结果返回。
###
\ No newline at end of file
......@@ -2,6 +2,7 @@ package com.geekq.miaosha.mybatis.Mapper;
import com.geekq.miaosha.mybatis.entity.User;
import com.geekq.miaosha.mybatis.vo.TeacherListVo;
import com.geekq.miaosha.mybatis.vo.TeacherVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -41,4 +42,6 @@ public interface UserMapper {
public List<TeacherVo> getTeacherAndUserList( @Param("uId") List<Integer> uId );
public List<TeacherListVo> getTeacherAndUserListVo(@Param("uId") Integer uId );
}
......@@ -3,6 +3,7 @@ package com.geekq.miaosha.mybatis.controller;
import com.geekq.miaosha.access.AccessLimit;
import com.geekq.miaosha.mybatis.Mapper.UserMapper;
import com.geekq.miaosha.mybatis.entity.User;
import com.geekq.miaosha.mybatis.vo.TeacherListVo;
import com.geekq.miaosha.mybatis.vo.TeacherVo;
import com.geekq.miaosha.redis.KeyPrefix;
import com.geekq.miaosha.redis.RedisService;
......@@ -98,7 +99,18 @@ public class UbatisController {
list.add(1);
list.add(2);
List<TeacherVo> teacherAndUser = userMapper.getTeacherAndUserList(list );
List<TeacherVo> teacherAndUser = userMapper.getTeacherAndUserList(list);
System.out.println(teacherAndUser.size());
}
/**
* 测试多表联合查询 in
*/
@RequestMapping(value = "/testAssc", produces = "text/html")
@ResponseBody
public void testAssc(){
List<TeacherListVo> teacherAndUser = userMapper.getTeacherAndUserListVo(1 );
System.out.println(teacherAndUser.toString());
}
}
package com.geekq.miaosha.mybatis.vo;
import com.geekq.miaosha.mybatis.entity.User;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.List;
@Setter
@Getter
public class TeacherListVo implements Serializable {
private String tId ;
private Integer uId ;
private String tName ;
private User userList;
@Override
public String toString() {
return "TeacherListVo{" +
"tId='" + tId + '\'' +
", uId=" + uId +
", tName='" + tName + '\'' +
", userList=" + userList +
'}';
}
}
......@@ -23,12 +23,12 @@ log4j.logger.java.sql.PreparedStatement=DEBUG
#mybatis
mybatis.type-aliases-package=com.geekq.miaosha.domain
#开启驼峰转换 configuration config-location 不能同時存在 如果要走流程 请 放开注释
mybatis.configuration.map-underscore-to-camel-case=true
#mybatis.configuration.map-underscore-to-camel-case=true
#mybatis.mapperLocations = classpath:com/geekq/miaosha/dao/*.xml
mybatis.mapperLocations=classpath:mybatis/mapper/*.xml
#配置xml方式 因为与 mybatis.configuration.map-underscore-to-camel-case 仅用于测试
#mybatis.config-location=classpath:mybatis/mybatis-config.xml
mybatis.config-location=classpath:mybatis/mybatis-config.xml
#add mybatis
mybatis.
......
......@@ -32,7 +32,7 @@ userMapper(userMapper.xml文件去除后缀)保证唯一性
</resultMap>
<resultMap type="com.geekq.miaosha.mybatis.vo.TeacherVo" id="TandUResultMap">
<resultMap type="com.geekq.miaosha.mybatis.vo.TeacherListVo" id="TandUResultMap">
<!-- id表示查询结果集中唯一标识
column:查询出的列名
property:type所指定的POJO中的属性名
......@@ -42,9 +42,12 @@ userMapper(userMapper.xml文件去除后缀)保证唯一性
<!-- 对普通列的映射定义 -->
<result column="t_id" property="tId"/>
<result column="t_name" property="tName"/>
<result column="name" property="name"/>
<result column="age" property="age"/>
<result column="_address" property="address"/>
<!--property="supervisor"表明这是为了映射学生实体的
supervisor属性。javaType="Teacher"用到了Teacher这个
别名定义,并指出了supervisor属性的java类型-->
<association property="userList" javaType="com.geekq.miaosha.mybatis.entity.User" column="u_id" select="com.geekq.miaosha.mybatis.Mapper.getUser" >
</association>
</resultMap>
<sql id="base_column">
......@@ -95,6 +98,10 @@ userMapper(userMapper.xml文件去除后缀)保证唯一性
</select>
<select id="getTeacherAndUserListVo" resultMap="TandUResultMap">
select * from teacher t where t.u_id = #{uId}
</select>
<!-- 插入自动递增-->
<insert id="insert" parameterType="com.geekq.miaosha.mybatis.entity.User"
useGeneratedKeys="true" keyProperty="id">
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册