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语句来抓取这个对象.这一个过程称为延迟加载. 二.延迟加载 ...
随机推荐
- VS2010 Notes
1.fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏 VS2010在经历一些更新后,建立Win32 Console Project时会出“error LNK112 ...
- line-height 与垂直居中!
在此之前,对于line-height 与垂直居中的问题,经常碰到. 比如,图片与span在同一个box中的时候,竟然会各种偏移.要想达到理想的效果真的是各种难. 有时间,决定认真的啃一啃. 一 lin ...
- SQL技术内幕-10 in和exists 性能比较
in和exists in 是把外表和内表作hash 连接,而exists是对外表作loop循环,每次loop循环再对内表进行查询. 一直以来认为exists比in效率高的说法是不准确的. 如果查询的两 ...
- App接口设计
关于APP接口设计 http://blog.csdn.net/gebitan505/article/details/37924711/
- Python 融于ASP框架
一.ASP的平反 想到ASP 很多人会说 “asp语言很蛋疼,不能面向对象,功能单一,很多东西实现不了” 等等诸如此类. 以上说法都是错误的,其一ASp不是一种语言是 微软用来代替CGI的一种web框 ...
- dom对象详解--document对象(二)
dom对象详解--style对象 style对象 style对象和document对象下的集合对象styleSheets有关系,styleSheets是文档中所有style对象的集合,这里讲解的 ...
- Android 核心分析之十二Android GEWS窗口管理之基本架构原理
Android GWES之窗口管理之基本构架原理 Android的窗口管理是C/S模式的.Android中的Window是表示Top Level等顶级窗口的概念.DecorView是Window的To ...
- JavaWeb项目开发案例精粹-第4章博客网站系统-002辅助类及配置文件
1. <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5&qu ...
- Head First HTML5 Programming笔记--chapter1 认识HTML5
升级到HTML5 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 //EN" "http://www.w3.org/TR/ ...
- backbone todo example
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...