1、sort可以直接添加在命名格式的字段中

 List<BomMain> findAllByDeleted(Integer deleted, Sort sort);

2、可以作为pageable的一个参数使用

 Page<Originals> selectBomSeriesList(Pageable pageable);

向sort传参的方式

1、装入Pageable使用

 Sort sort = new Sort(Sort.Direction.ASC, "serieName");

         Pageable pageable = PageRequest.of(0, 10, sort);

         Page<Originals> list = bomSeriesRepository.selectBomSeriesList(pageable);

         System.out.println(list.getTotalPages());

2、自行使用

 Sort sort = new Sort(Sort.Direction.ASC, "sequence");

         List<BomMain> bomMainList = bomMainRepository.findAllByDeleted(1, sort);

         log.info("列表" + gson.toJson(bomMainList));

3、多个条件表关联使用

   List<Sort.Order> listOrder = new ArrayList<>();

         listOrder.add(new Sort.Order(Sort.Direction.ASC, "bomMain.sequence"));

         listOrder.add(new Sort.Order(Sort.Direction.ASC, "sequence"));

         Sort sort = Sort.by(listOrder);

         List<BomSub> bomSubList = bomSubRepository.findAllByDeletedAndBomMainMainId(1, "1", sort);

         log.info("列表" + gson.toJson(bomSubList));

生成SQL

 SELECT
bomsub0_.subId AS subId1_9_,
bomsub0_.mainId AS mainId8_9_,
bomsub0_.deleted AS deleted2_9_,
bomsub0_.engName AS engName3_9_,
bomsub0_.fullName AS fullName4_9_,
bomsub0_.isOnShelf AS isOnShel5_9_,
bomsub0_.sequence AS sequence6_9_,
bomsub0_.subName AS subName7_9_
FROM
bomsub bomsub0_
LEFT OUTER JOIN bommain bommain1_ ON bomsub0_.mainId = bommain1_.mainId
WHERE
bomsub0_.deleted =?
AND bommain1_.mainId =?
ORDER BY
bommain1_.sequence ASC,
bomsub0_.sequence ASC

IntelliJ IDEA 2017版 spring-boot2.0.2 搭建 JPA springboot DataSource JPA sort排序方法使用方式, 添加关联表的 order by的更多相关文章

  1. IntelliJ IDEA 2017版 spring-boot2.0.2 搭建 JPA springboot DataSource JPA环境搭建,JPA实现非字符型设置长度

    1.在github上已有配置环境,如下链接,(需要环境JDK1.8及以上版本,Tomcat1.8及以上版本,搭建maven库,使用编译器IntellJ IDEA) https://github.com ...

  2. IntelliJ IDEA 2017版 spring-boot2.0.2 搭建 JPA springboot DataSource JPA 实体类浅谈

    一.实体类分析 一般用到的实体类的类型有 String类型.Long类型.Integer类型.Double类型.Date类型.DateTime类型.Text类型.Boolean型等 1.String类 ...

  3. IntelliJ IDEA 2017版 spring-boot2.0.2 搭建 JPA springboot DataSource JPA环境搭建,JPA注解@ManyToOne使用详情;JPA外键设置

    一.数据库原型 数据库模型如图所示,而现在需要根据数据库模型,建立对应的实体类,这在项目重构老数据库,采用新的框架重构上应该是比较常见的. 数据库脚本如下: CREATE TABLE `bomsub` ...

  4. spring boot2.0(一 ) 基础环境搭建

    1.基础配置 开发环境:window jdk版本:1.8(spring boot2.0最低要求1.8) 开发工具:eclipse 构建方式:maven3 2.POM配置文件 <project x ...

  5. Spring Boot2.0 设置拦截器

    所有功能完成 配置登录认证 配置拦截器 在spring boot2.0 之后 通过继承这个WebMvcConfigurer类 就可以完成拦截 新建包com.example.interceptor; 创 ...

  6. Spring Boot2.0 静态资源被拦截问题

    在Spring Boot2.0+的版本中,只要用户自定义了拦截器,则静态资源会被拦截.但是在spring1.0+的版本中,是不会拦截静态资源的. 因此,在使用Spring Boot2.0+时,配置拦截 ...

  7. Spring Boot2.0使用Spring Security

     一.Spring Secutity简介     Spring 是一个非常流行和成功的 Java 应用开发框架.Spring Security 基于 Spring 框架,提供了一套 Web 应用安全性 ...

  8. Spring Boot2.0 整合 Kafka

    Kafka 概述 Apache Kafka 是一个分布式流处理平台,用于构建实时的数据管道和流式的应用.它可以让你发布和订阅流式的记录,可以储存流式的记录,并且有较好的容错性,可以在流式记录产生时就进 ...

  9. Spring Boot2.0自定义配置文件使用

    声明: spring boot 1.5 以后,ConfigurationProperties取消locations属性,因此采用PropertySource注解配合使用 根据Spring Boot2. ...

随机推荐

  1. [java,2017-05-15] 内存回收 (流程、时间、对象、相关算法)

    内存回收的流程 java的垃圾回收分为三个区域新生代.老年代. 永久代 一个对象实例化时 先去看伊甸园有没有足够的空间:如果有 不进行垃圾回收 ,对象直接在伊甸园存储:如果伊甸园内存已满,会进行一次m ...

  2. oracle自定义函数返回结果集

    首先要弄两个type,不知道什么鬼: 1. create or replace type obj_table as object ( id ), name ), ) ) 2. create or re ...

  3. leetcode309

    使用动态规划,下面的代码可以通过210个测试,最后1个(第211个)会超时.说明思路是正确的,但是其中有一些是无效的计算. class Solution { public: int maxProfit ...

  4. Sphinx 安装与使用

    Sphinx 优点 高速索引(接近10M/S) 高速搜索(2-4G文本搜索耗时不到0.1秒) 高可用性(单CPU支持100GB文本,100M文档) 提供相关性排名.分布式搜索.文档摘要(高亮显示) S ...

  5. PHP 设计模式(一)

    基础的三种设计模式 工厂模式 为创建对象提供了一个统一的接口,好处是当被创建对象命名空间或者名称改变时,直接修改工厂的创建方法即可 <?php class Factory{ public sta ...

  6. BBS(第三天) 如何吧用户上传的图片文件保存到本地

    1. 将用户上传的所有静态文件统一管理 -- settings.py -- MEDIA_ROOT = os.path.join(BASE_DIR, 'media') 2. 服务器会对外公开一下服务器静 ...

  7. PHPMailer出现SMTP connect() failed.

    很可能是端口问题,最好把$mailer->SMTPSecure和$mailer->Port分别设置为ssl与465或者tls与587,否则某些浏览器不接受不安全的链接,导致$mailer- ...

  8. 解决 jdk8 Illegal key size or default parameters 错误

    网上搜到的答案如:https://blog.csdn.net/educast/article/details/81060085  大多是jdk1.6或1.7版本,有的jdk是1.8.99之前的版本,而 ...

  9. Javascript面试题收集

    第一部分“ 来源: http://bbs.miaov.com/forum.php?mod=viewthread&tid=6974 1.var a = b = 1; ——这样定义变量的隐患 fu ...

  10. python 安装包制作

    1. __init__.py 2.模块1 模块2 3.setup.py from distutils.core import setup setup(name='modules_name',versi ...