hibernate中使用fetch来决策性能方案
什么时候用子查询,或者连接查询
一般多个数据的对应用子查询,单一行的数据用连接
(若要查询每个学生分别学了什么课程 ,若要fetch=join、fetch=select)
则是这种情况
Hibernate:
select
student0_.sid as sid2_,
student0_.s_name as s2_2_
from
student student0_
Hibernate:
select
courses0_.sid as sid2_1_,
courses0_.cid as cid1_,
course1_.cid as cid0_0_,
course1_.c_name as c2_0_0_
from
student_course courses0_
inner join
course course1_
on courses0_.cid=course1_.cid
where
courses0_.sid=?
freedom:odijfoij
freedom:in2
Hibernate:
select
courses0_.sid as sid2_1_,
courses0_.cid as cid1_,
course1_.cid as cid0_0_,
course1_.c_name as c2_0_0_
from
student_course courses0_
inner join
course course1_
on courses0_.cid=course1_.cid
where
courses0_.sid=?
wer:odijfoij
Hibernate:
select
courses0_.sid as sid2_1_,
courses0_.cid as cid1_,
course1_.cid as cid0_0_,
course1_.c_name as c2_0_0_
from
student_course courses0_
inner join
course course1_
on courses0_.cid=course1_.cid
where
courses0_.sid=?
ert:odijfoij
Hibernate:
select
courses0_.sid as sid2_1_,
courses0_.cid as cid1_,
course1_.cid as cid0_0_,
course1_.c_name as c2_0_0_
from
student_course courses0_
inner join
course course1_
on courses0_.cid=course1_.cid
where
courses0_.sid=?
qqs:odijfoij
子查询的效率:
Hibernate:
select
student0_.sid as sid2_,
student0_.s_name as s2_2_
from
student student0_
Hibernate:
select
courses0_.sid as sid2_1_,
courses0_.cid as cid1_,
course1_.cid as cid0_0_,
course1_.c_name as c2_0_0_
from
student_course courses0_
inner join
course course1_
on courses0_.cid=course1_.cid
where
courses0_.sid in (
select
student0_.sid
from
student student0_
)
freedom:in2
freedom:odijfoij
wer:odijfoij
ert:odijfoij
qqs:odijfoij
hibernate中使用fetch来决策性能方案的更多相关文章
- Hibernate中得fetch
fetch ,可以设置fetch = "select" 和 fetch = "join" 用一对多来举例:fetch = "select"是 ...
- Hibernate中的延迟加载及fetch
Hibernate中的延迟加载 1.类级别的查询策略: lazy : true(默认值) false(立即加载) 2.多对一关联的查询策略: lazy: proxy(默认值) no-proxy ...
- Hibernate中延迟加载和缓存
什么是延迟加载? 延迟加载是指当应用程序想要从数据库获取对象时(在没有设置lazy属性值为false),Hibernate只是从数据库获取符合条件的对象的OId从而生成代理对象,并没有加载出对象 访问 ...
- hibernate 中文文档
转载:http://blog.csdn.net/kevon_sun/article/details/42850387 Hibernate Annotations 参考文档 3.2.0 CR1 目录 前 ...
- hibernate中的缓存机制
一.为什么要用Hibernate缓存? Hibernate是一个持久层框架,经常访问物理数据库. 为了降低应用程序对物理数据源访问的频次,从而提高应用程序的运行性能. 缓存内的数据是对物理数据源中的数 ...
- [转载]Hibernate如何提升数据库查询的性能
目录(?)[-] 数据库查询性能的提升也是涉及到开发中的各个阶段在开发中选用正确的查询方法无疑是最基础也最简单的 SQL语句的优化 使用正确的查询方法 使用正确的抓取策略 Hibernate的性能优化 ...
- Hibernate中的事务处理流程详解
一.Hibernate操作的基本流程 使用 Hibernate 进行数据持久化操作,通常有如下步骤: 1.编写持久化类: POJO + 映射文件 2.获取 Configuration 对象 3.获取 ...
- 使用Redis在Hibernate中进行缓存
Hibernate是Java编程语言的开放源代码,对象/关系映射框架.Hibernate的目标是帮助开发人员摆脱许多繁琐的手动数据处理任务.Hibernate能够在Java类和数据库表之间以及Java ...
- (十六)Hibernate中的延迟加载
一.什么是延迟加载 为了节省Hibernate加载对象的性能节销,在Hibernate中真正需要用到这个对象时,才会发出 SQL语句来抓取这个对象.这一个过程称为延迟加载. 二.延迟加载 ...
随机推荐
- iOS-OpenGLES 简单渲染
UIImage *showImage = [UIImage imageNamed:, , showImage.size.width, showImage.size.height); ) fo ...
- Android屏幕适应详解(二)
android应用自适应多分辨率的解决方法 1. 首先是建立多个layout文件夹(drawable也一样). 在res目录下建立多个layout文件夹,文件夹名称为layout-800x480等. ...
- WCF分布式开发步步为赢(5)服务契约与操作重载
继上一节WCF分布式开发步步为赢系列的(4):WCF服务可靠性传输配置与编程开发,本节我们继续学习WCF分布式开发步步为赢的第(5)节:服务契约与操作重载.这里我们首先讲解OOP面向对象的编程中方法重 ...
- UVA 11806 Cheerleaders dp+容斥
In most professional sporting events, cheerleaders play a major role in entertaining the spectators. ...
- UVA 11609 Teams 组合数学+快速幂
In a galaxy far far away there is an ancient game played among the planets. The specialty of the gam ...
- Codeforces Round #336 (Div. 2) A. Saitama Destroys Hotel 模拟
A. Saitama Destroys Hotel Saitama accidentally destroyed a hotel again. To repay the hotel company ...
- Gradle Goodness: Continue Build Even with Failed Tasks
If we run a Gradle build and one of the tasks fails, the whole build stops immediately. So we have f ...
- android-exploitme(二):安装apk熟悉测试环境
今天我们来熟悉测试环境: 1. 下载server代码,并运行 git clone https://github.com/SecurityCompass/LabServer.git 2. 这个serve ...
- Redis通用操作(适用于String,Hash,链表等)
keys pattern 查询相应的key 在redis里,允许模糊查询key 有3个通配符 *, ? ,[] *: 通配任意多个字符 ?: 通配单个字符 []: 通配括号内的某1个字符 redis ...
- struts2与struts1整合,Unable to load configuration. - interceptor-ref ... struts.xml
struts.xml中为了与struts1的MVC模式整合,需要类似如下的拦截器的引用 <interceptor-stack name="integration"> & ...