什么时候用子查询,或者连接查询

一般多个数据的对应用子查询,单一行的数据用连接

(若要查询每个学生分别学了什么课程 ,若要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来决策性能方案的更多相关文章

  1. Hibernate中得fetch

    fetch ,可以设置fetch = "select" 和 fetch = "join" 用一对多来举例:fetch = "select"是 ...

  2. Hibernate中的延迟加载及fetch

    Hibernate中的延迟加载 1.类级别的查询策略: lazy  :  true(默认值) false(立即加载) 2.多对一关联的查询策略: lazy:  proxy(默认值) no-proxy ...

  3. Hibernate中延迟加载和缓存

    什么是延迟加载? 延迟加载是指当应用程序想要从数据库获取对象时(在没有设置lazy属性值为false),Hibernate只是从数据库获取符合条件的对象的OId从而生成代理对象,并没有加载出对象 访问 ...

  4. hibernate 中文文档

    转载:http://blog.csdn.net/kevon_sun/article/details/42850387 Hibernate Annotations 参考文档 3.2.0 CR1 目录 前 ...

  5. hibernate中的缓存机制

    一.为什么要用Hibernate缓存? Hibernate是一个持久层框架,经常访问物理数据库. 为了降低应用程序对物理数据源访问的频次,从而提高应用程序的运行性能. 缓存内的数据是对物理数据源中的数 ...

  6. [转载]Hibernate如何提升数据库查询的性能

    目录(?)[-] 数据库查询性能的提升也是涉及到开发中的各个阶段在开发中选用正确的查询方法无疑是最基础也最简单的 SQL语句的优化 使用正确的查询方法 使用正确的抓取策略 Hibernate的性能优化 ...

  7. Hibernate中的事务处理流程详解

    一.Hibernate操作的基本流程 使用 Hibernate 进行数据持久化操作,通常有如下步骤: 1.编写持久化类: POJO + 映射文件 2.获取 Configuration 对象 3.获取 ...

  8. 使用Redis在Hibernate中进行缓存

    Hibernate是Java编程语言的开放源代码,对象/关系映射框架.Hibernate的目标是帮助开发人员摆脱许多繁琐的手动数据处理任务.Hibernate能够在Java类和数据库表之间以及Java ...

  9. (十六)Hibernate中的延迟加载

    一.什么是延迟加载 为了节省Hibernate加载对象的性能节销,在Hibernate中真正需要用到这个对象时,才会发出        SQL语句来抓取这个对象.这一个过程称为延迟加载. 二.延迟加载 ...

随机推荐

  1. jquery ajax post 传递数组 ,多checkbox 取值

    jquery ajax post 传递数组 ,多checkbox 取值 http://w8700569.iteye.com/blog/1954396 使用$.each(function(){});可以 ...

  2. 视频转换工具 Transmageddon

    点这里 Transmageddon 是一个采用 Python 语言开发的视频转换工具,支持输出几乎所有的视频格式,同时也可以生成指定平台下的视频格式. 软件界面如下图所示

  3. spring PropertyPlaceholderConfigurer 找不到配置文件原因

    1:  spring 版本问题 参见: http://www.cnblogs.com/alex-blog/archive/2012/12/25/2832357.html 2: bean id 同名   ...

  4. C# Socket 入门3 UPD(转)

    今天来写一个UPD 1.服务端: using System; using System.Collections.Generic; using System.Text; using System.Net ...

  5. odata

    http://www.odata.org/ Open Data Protocol (开放数据协议,OData)是用来查询和更新数据的一种Web协议,其提供了把存在于应用程序中的数据暴露出来的方式.OD ...

  6. 李洪强iOS开发之下载

    // // //  LHQDownLoader.m //  A21 - 李洪强 - 下载 // //  Created by vic fan on 16/7/3. //  Copyright © 20 ...

  7. JSTL标签库中fmt标签,日期,数字的格式化

    首先介绍日期的格式化:(不要嫌多哦) JSTL格式化日期(本地化) 类似于数字和货币格式化,本地化环境还会影响生成日期和时间的方式. <%@ page pageEncoding="UT ...

  8. ps小技巧

    一.加色与减色 电脑显示器和电视是加色法最常见的形式,而在油漆.颜料和彩色滤光片会用减色. 二.怎么把背景变成透明:其实就是抠图. 1.魔术棒+delete,缺点:应用于边界明显的图片,否则容差不好控 ...

  9. JavaWeb笔记——上传文件

    jsp上传文件 *<form>标签method属性必须为post,并且添加enctype="multipart/form-data"属性   ------------- ...

  10. CentOS配置SSH单向无密码访问

    最近在研究一款文件系统,需要远程给客户机安装软件,且需要无SSH密码访问,另外需要远程给客户机传文件,每次输入root密码很不方便,就想到用ssh key生成公钥.私钥来验证,而避免每次就必须输入ro ...