这两天开了一个新项目,使用SpringBoot+SpringData, 刚做了一个小功能,都是一张表的操作没什么问题,今天设计到了两张表联查,两张表各取了几个字段,组合成了一个vo, 当我用原生sql查询时报出 "找不到转换器",当我用JPQL查询时,报出 xxx is not mapped.. 着实浪费了些时间. 其实最大的根本原因在于, 当使用JPQL 查询时,我们 FROM 的表名就不能是实体上@Table 注解中的表名,而是对应的实体的类名,记住是类名,并且查询的字段要是…
对方法进行日志输出是一种很常见的功能.传统的做法是把输出语句写在方法体的内部,在调用该方法时,用输入语句输出信息来记录方法的执行! 1.先写一个普通类: package com.importnew; public class Common { public void execute(String username,String password){ System.out.println("------------------执行 execute()方法----------------"…
public Pagination getLookPage(BeanPatrolScheduling beanPatrolScheduling, int pageNo, int pageSize) { SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd"); Pagination pagination = new Pagination(); StringBuffer sql = new StringBuffer(…
spring jdbcTemplate query 返回值为null 今天使用以下方法从数据库中查询数据,返回列表 public List<BookBean> getBooks(){ String sql = "select * from books where inventory > 0 order by title"; List<BookBean> books = jdbcTemplate.query(sql, new BeanPropertyRowM…