28 复杂的使用Specification查询
/**
* Specification的多表查询
*/
@Test
public void testFind() {
Specification<LinkMan> spec = new Specification<LinkMan>() {
public Predicate toPredicate(Root<LinkMan> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
//Join代表链接查询,通过root对象获取
//创建的过程中,第一个参数为关联对象的属性名称,第二个参数为连接查询的方式(left,inner,right)
//JoinType.LEFT : 左外连接,JoinType.INNER:内连接,JoinType.RIGHT:右外连接
Join<LinkMan, Customer> join = root.join("customer",JoinType.INNER);
return cb.like(join.get("cName").as(String.class),"张三");
}
};
List<LinkMan> list = linkManDao.findAll(spec);
for (LinkMan linkMan : list) {
System.out.println(linkMan);
}
}
28 复杂的使用Specification查询的更多相关文章
- springDataJPQL实现增删改查及分页,原生sql查询,根据方法命名规则实现查询以及Specification查询
一.使用方法 1.在dao中定义开一个方法,使用方法的参数设置jpql,并且使用方法的返回值接受查询结果,在方法上添加@query注解,在注解中写jpql语句进行增删改查,测试 2.使用原生的sql语 ...
- Django【第28篇】:优化查询的方式
优化查询的方式 一.假设有三张表 Room id 1 2 .. 1000 User: id 1 .. 10000 Booking: user_id room_id time_id date 1 1 8 ...
- Spring data jpa Specification查询关于日期的范围搜索
代码: 时间格式化类型: SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat s ...
- JPA使用Specification构建动态查询
封装Specification查询条件,在Spring Data JPA 2.0以前使用 Specifications 这个辅助类来操作where.not.and和or连接,在2.0版本以后这个类会被 ...
- spring data jpa Specification 复杂查询+分页查询
当Repository接口继承了JpaSpecificationExecutor后,我们就可以使用如下接口进行分页查询: /** * Returns a {@link Page} of entitie ...
- spring data jpa Specification动态查询
package com.ytkj.entity; import javax.persistence.*; import java.io.Serializable; /** * @Entity * 作用 ...
- JPA查询之Specification以及HQL、SQL查询
1.Specification //查询条件List List<Predicate> predicateList = new ArrayList<Predicate>(); S ...
- MongoDB常用操作一查询find方法db.collection_name.find()
来:http://blog.csdn.net/wangli61289/article/details/40623097 https://docs.mongodb.org/manual/referenc ...
- JPA的多表复杂查询
转 JPA的多表复杂查询:详细篇 原文链接: https://mp.weixin.qq.com/s/7J6ANppuiZJccIVN-h0T3Q 2017-11-10 从小爱喝AD钙 最近工作中由于 ...
随机推荐
- 管理Exchange Online用户介绍(一)
一.管理收件人 1.在“Office 365管理中心”主页,依次选择用户->添加用户 2.输入相关信息,其中包括名称.用户名.电子邮件地址等信息. 二.Exchange Online对用户邮箱的 ...
- TPO1-1 Groundwater
If the pores are large,the water in them will exist as drops too heavy for surface tension to hold,a ...
- Pytorch中的variable, tensor与numpy相互转化的方法
1.将numpy矩阵转换为Tensor张量 sub_ts = torch.from_numpy(sub_img) #sub_img为numpy类型 2.将Tensor张量转化为numpy矩阵 sub_ ...
- Python实现:生产者消费者模型(Producer Consumer Model)
#!/usr/bin/env python #encoding:utf8 from Queue import Queue import random,threading,time #生产者类 clas ...
- MOOC(3)- python发送请求,返回的json数据被转码
https://www.cnblogs.com/yoyoketang/p/10339210.html 问题:发送post请求,对post请求返回的json数据格式化,但是返回的结果被转码了 json. ...
- 介绍vue-cli脚手架config目录下index.js配置文件
1.config/index.js var path = require('path') module.exports = { build: { // production 环境 env: requi ...
- jQuery 源码学习 - 02 - jQuery.fn.extend 与 jQuery.extend
参考资料:[深入浅出jQuery]源码浅析--整体架构,备用地址:chokcoco/jQuery-. extend 方法在 jQuery 中是一个很重要的方法.jQuery 内部用它来拓展静态方法或者 ...
- 第十届javaB(5)
试题 E: 迷宫 本题总分:15 分[问题描述] 下图给出了一个迷宫的平面图,其中标记为 1 的为障碍,标记为 0 的为可 以通行的地方.010000 000100 001001 110000迷宫的入 ...
- 正则提取关键字符-python代码实现
原文地址:http://www.bugingcode.com/blog/python_re_extraction_key.html 关于python的正则使用在以前的文章中 http://www.bu ...
- shell知多少?
Shell字面理解就是个"壳",是操作系统(内核)与用户之间的桥梁,充当命令解释器的作用,将用户输入的命令翻译给系统执行.Linux中的shell与Windows下的DOS一样,提 ...