码迷,mamicode.com
首页 > 编程语言 > 详细

springboot + jpa

时间:2018-10-19 13:58:28      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:aaa   script   prope   epo   match   system   str   concat   排序   

例子

public void aaa() {
    //1. @Query
    List<LogisticsFinanceDayOrder> list1 = logisticsFinanceDayOrderDao.ccc();
    LogisticsFinanceDayOrder list2 = logisticsFinanceDayOrderDao.ccc2("5");
    List<String> list3 = logisticsFinanceDayOrderDao.ccc3("18日");
    //2. 排序查询
    Sort sort=new Sort(Sort.Direction.DESC,"id");
    List<LogisticsFinanceDayOrder> list = logisticsFinanceDayOrderDao.findAll(sort);
    System.out.println("ccc");
    //3. 分页排序查询
    PageRequest pageRequest = PageRequest.of(0,4,sort);
    Page<LogisticsFinanceDayOrder> page = logisticsFinanceDayOrderDao.findAll(pageRequest);
    System.out.println("ccc");
    //4. 实体匹配查询
    LogisticsFinanceDayOrder logisticsFinanceDayOrder = new LogisticsFinanceDayOrder();
    //logisticsFinanceDayOrder.setId("5");
    logisticsFinanceDayOrder.setDescription("18日");
    ExampleMatcher exampleMatcher = ExampleMatcher.matching().withMatcher("description", ExampleMatcher.GenericPropertyMatchers.startsWith());
    Example example = Example.of(logisticsFinanceDayOrder,exampleMatcher);
    List<LogisticsFinanceDayOrder> l = logisticsFinanceDayOrderDao.findAll(example);
}
@Repository
public interface LogisticsFinanceDayOrderDao extends BaseDao<LogisticsFinanceDayOrder>, LogisticsFinanceDayOrderDaoCustom {
    @Query("from LogisticsFinanceDayOrder")
    public List<LogisticsFinanceDayOrder> ccc();

    @Query("from LogisticsFinanceDayOrder where id = ?1")
    public LogisticsFinanceDayOrder ccc2(String id);

    @Query("select orderNo from LogisticsFinanceDayOrder where description like CONCAT(:description,‘%‘)")
    public List<String> ccc3(@Param("description") String description);
}

 

springboot + jpa

标签:aaa   script   prope   epo   match   system   str   concat   排序   

原文地址:https://www.cnblogs.com/yifanSJ/p/9815638.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!