/**
* HQL的内连接查询
* String hql="from Customer c inner join fetch c.linkmans";
*/
@Test
public void test8(){
Session session = HibernateUtil.getCurrentSession();
Transaction tr = session.beginTransaction(); /**
* 内连接:显示内连接 on / 隐示内连接 where
* 内连接:交集部分
* 左外连接:左表加交集部分(除了交集部分,其它为null)
* 右外连接:右表加交集部分(除了交集部分,其它为null)
* 迫切连接:fetch(hibernate框架提供的:用来将查询的数据转换为对象的形式)
*/
Query query = session.createQuery("from Customer c inner join fetch c.linkmans");
/**
* 将List集合转换为Set集合可以避免重复数据
*/
List<Customer> list = query.list();
Set<Customer> set=new HashSet<Customer>(list);
for (Customer customer : set) {
System.out.println(customer);
} tr.commit();
HibernateUtil.closeCurrentSession(); }

  

HQL的内连接查询的更多相关文章

  1. mysql——多表——内连接查询

    内连接查询:可以查询两个或者两个以上的表,当两个表中存在表示相同意义的字段时,可以通过该字段来连接这两个表: 当该字段的值相等时,就查询出该记录. 前期准备两个表: ), d_id ), name ) ...

  2. MySQL多表查询合并结果union all,内连接查询

    MySQL多表查询合并结果和内连接查询 1.使用union和union all合并两个查询结果:select 字段名 from tablename1 union select 字段名 from tab ...

  3. mysql求交集:UNION ALL合并查询,inner join内连接查询,IN/EXISTS子查询

    两个要求交集的表(列)的结构要一致,对应的字段数,字段类型都应该相同:将两个数据的数据列用 UNION ALL 关键字合并:将上面的所有需要比较的列 GROUP BY :最后 HAVING COUNT ...

  4. MySQL内连接查询

    1.语法: select 字段列表 from table1,table2 where 子句: select 字段列表 from table1 as 别名1 inner join table2 as 别 ...

  5. mysql内连接查询之自连接

    连接查询: 当查询数据时,通过连接操作查询出存放在多个表中的不同数据,当两个或者多个表中存在相同意义的字段时, 便可以通过这些字段对不同的表进行连接查询. 自连接: 如果在一个连接查询中,涉及的两个表 ...

  6. mysql常用基础操作语法(八)~~多表查询合并结果和内连接查询【命令行模式】

    1.使用union和union all合并两个查询结果:select 字段名 from tablename1 union select 字段名 from tablename2: 注意这个操作必须保证两 ...

  7. 内连接查询输出到datagridView

    实现步骤: 1. 新建两张对应表的类 例如: 第一张表对应的类 { class ManagerInfo { public Table1 group { get; set; } //重点 需要内连接的字 ...

  8. Mysql学习总结(24)——MySQL多表查询合并结果和内连接查询

    1.使用union和union all合并两个查询结果:select 字段名 from tablename1 union select 字段名 from tablename2: 注意这个操作必须保证两 ...

  9. 【MySQL作业】连接查询——美和易思内连接查询应用习题

    点击打开所使用到的数据库>>> 1.使用内连接获取客户"王传华"所有的订单信息和客户信息. 使用内连接获取客户"王传华"所有的订单信息和客户信 ...

随机推荐

  1. Mysql select id 加上order by 后结果不一致

    测试数据将近280万 1.SELECT id FROM cbbd ORDER BY id LIMIT 900000,10 2.SELECT id FROM cbbd  LIMIT 900000,10 ...

  2. es6笔记(6) Iterator 和 for...of循环

    概要 js中的数组.对象,加上ES6中增加的Map.Set四种数据集合. Iterator提供了一种机制,为各种不同的数据结构提供统一的访问机制.任何数据结构只要部署Iterator接口,就可以完成遍 ...

  3. Requests中出现大量ASYNC_NETWORK_IO等待

    七夕活动,网页显示异常:504 Gateway Time-out The server didn't respond in time.开发询问数据库是否正常,当时正连接在实例上查询数据,感觉响应确实慢 ...

  4. python 入门基础23 选课系统 项目

    选课系统 代码地址:github_code # 选课系统 # 角色:学校.学员.课程.讲师 # 要求: # 1. 创建北京.上海 2 所学校 # 2. 创建linux , python , go 3个 ...

  5. Maven从私服上下载所需jar包——(十四)

    1.修改settings.xml 将下面代码添加到settings.xml中 <profile> <!--profile的id--> <id>dev</id& ...

  6. Nuts & Bolts Problem

    Given a set of n nuts of different sizes and n bolts of different sizes. There is a one-one mapping ...

  7. 高通Trustzone and QSEE介绍

    http://blog.csdn.net/iamliuyanlei/article/details/52625968

  8. mydumper安装及使用

    mydumper 官网:https://launchpad.net/mydumper 安装方式: 1.yum install glib2-devel mysql-devel zlib-devel pc ...

  9. linux下查看各硬件型号

    查看主板型号 # dmidecode |grep -A 8 "System Information"System Information 上网查DELL CS24-TY,找到说主板 ...

  10. linux挂载mount参数优化

    一. 1) 蓝色:表示经过优化的xfs mount时的参数defaults,noatime,nodiratime,nobarrier,discard,allocsize=256m,logbufs=8, ...