Java_myBatis_XML代理_延迟加载
使用mybatis的延迟加载,需要两个步骤:
1.在全局配置文件中添加一下语句(lazyLoadingEnabled默认为false,aggressiveLazyLoading默认为true)
<settings>
<!-- 延迟加载总开关 -->
<setting name="lazyLoadingEnabled" value="true"/>
<!-- 侵入式延迟 -->
<setting name="aggressiveLazyLoading" value="false"/>
</settings>
2.写好映射文件
<resultMap type="User" id="CacheTest">
<id column="id" property="id" />
<result column="username" property="username" />
<result column="birthday" property="birthday" />
<result column="address" property="address" />
<!-- column相当于传入parameter ofType相当于resultType -->
<collection property="orderList" column="id" ofType="Order"
select="resultMap.resultMapMapper.CacheTestSelect">
<result column="number" property="number" />
<result column="createtime" property="createtime" />
</collection>
</resultMap>
<select id="CacheTest" resultMap="CacheTest">
select * from user
</select>
<select id="CacheTestSelect" parameterType="int" resultType="Order">
select * from orders where user_id = #{id}
</select>
这样查询一开始会执行select * from user
然后当读取到orderList时才会执行select * from orders where user_id = #{id}
Java_myBatis_XML代理_延迟加载的更多相关文章
- Java_myBatis_XML代理_动态SQL
主要是设计到映射文件的编写: SELECT: <sql id="query_user_where"> <!-- test里面可以编写OGNL表达式 --> ...
- nginx反向代理_负载均衡
注意ip地址为: 虚拟机ip设置 TYPE="Ethernet"BOOTPROTO="static"NAME="enp0s3"DEVICE= ...
- mybatis高级(3)_延迟加载_深度延迟_一级缓存_二级缓存
设置延迟加载需要在mybatis.xml中设置 注: 侵入式延迟加载为真时是延迟加载 侵入式延迟加载为假时是深度延迟加载 <!-- 延迟加载和深度延迟加载 --> <settings ...
- 代理_正向代理_反向代理_nginx_转
转自:Nginx 相关介绍(Nginx是什么?能干嘛?) 蔷薇Nina 关于代理 说到代理,首先我们要明确一个概念,所谓代理就是一个代表.一个渠道: 此时就设计到两个角色,一个是被代理角色,一个是 ...
- mybatis由浅入深day02_6延迟加载_延迟加载总结
6 延迟加载 6.1 什么是延迟加载 需要查询关联信息时,使用mybatis延迟加载特性可有效的减少数据库压力,首次查询只查询主要信息,关联信息等用户获取时再加载. resultMap可以实现高级映射 ...
- Mybatis3.1-[tp_34-35]-_映射文件_select_resultMap关联查询_collection定义关联集合封装规则_collection分步查询_延迟加载
笔记要点出错分析与总结工程组织 1.定义接口 interface DepartmentMapper package com.dao; import com.bean.Department; publi ...
- Mybatis3.1-[tp_32-33]-_映射文件_select_resultMap关联查询_association分步查询_延迟加载
笔记要点出错分析与总结 工程组织 1.定义接口 DepartmentMapper package com.dao; import com.bean.Department; public interfa ...
- Java_myBatis_xml代理写法
这种开发方式只需要写好Mapper.xml和对应的Interface就可以了. 1.编写Mapper.xml <?xml version="1.0" encoding=&qu ...
- hibernate延迟加载(get和load的区别)
概要: 在hibernate中我们知道如果要从数据库中得到一个对象,通常有两种方式,一种是通过session.get()方法,另一种就是通过session.load()方法,然后其实这两种方法在获得一 ...
随机推荐
- linux内核设计第七周——可执行程序的装载
- 可移动的 HelloWorld
package com.home.test; import java.awt.Color;import java.awt.Cursor;import java.awt.Font;import java ...
- 数学战神app(小学生四则运算app)开发需求及进度
项目名字:“数学战神” 开发环境:Android eclipse 团队名称:战神联盟 团队成员:陈思明,许家豪,王宏财,吴旭涛 在之前的四则运算APP中添加更多的实用功能,并在各种平台推广宣传. 预加 ...
- HDOJ4548_美素数
简单的素数问题 HDOJ4548_美素数 #include<stdio.h> #include<stdlib.h> #include<math.h> #includ ...
- Spring Cloud的Zuul的使用问题
Zuul Client 放在移动App中,Zuul Server可以做集群. Zuul Client放在jar包吗?ios怎么办? Zuul与Spring Security配合使用,与Shiro做集成 ...
- python之OrderedDict类
# OrderedDict类使用举例 # OrderedDict类的使用与字典相似,不同的是OrderedDict类会记录键值对的添加顺序 from collections import Ordere ...
- codeforces659B
Qualifying Contest CodeForces - 659B Very soon Berland will hold a School Team Programming Olympiad. ...
- python 模块之-configparser
python 模块configparser 配置文件模块 import configparser config = configparser.ConfigParser() config[&q ...
- jsp操作MySQL时报错:Operation not allowed after ResultSet closed
一个stmt对多个rs进行操作引起的ResultSet关闭的错误 解决办法:创建新的stmt,一个rs对应一个stmt
- 自学Linux Shell11.6-退出shell
点击返回 自学Linux命令行与Shell脚本之路 11.6-退出shell shell运行的每一个命令都是使用 退出状态码 告诉shell它已经运行完毕.退出状态码是一个0~255的整数值,在命令结 ...