我这样使用spring数据jpa:
public interface CpQualityRepository extends JpaRepository<CpQualityPO, Integer>, JpaSpecificationExecutor<CpQualityPO>
我有10条记录。如果page = 0且limit = 20则可以使用。但是当我将page设置为1时,会出现一些错误。在日志中,我发现了两个sql。一个普通的SQL和另一个有线的SQL。
Hibernate: SELECT a.id AS id, a.time AS createTime, a.item AS item, a.category AS category, a.biz AS business, a.c_type AS contentType, a.cp_api AS cpApi, a.dedup AS dedup, a.content_level AS contentLevel, a.reserve_cp_api AS reserveCpApi, SUM(b.value) AS dedupCount, SUM(c.value) AS originalCount FROM ......
Hibernate: select count(a) FROM statis_data AS a LEFT JOIN statis_data AS b ON a.id = b.id AND b.dedup = 1 LEFT JOIN statis_data AS c ON a.id = c.id AND
我不知道为什么Spring数据会创建本机查询中没有的'select count(a)'。 FROM子句之后的两个sql相同。
此外,休眠:由于没有名为a的列,因此select count(a)不起作用。
错误消息:
2019-05-31 13:18:09警告[http-nio-8080-exec-5] o.h.e.j.s.SqlExceptionHelper:129-SQL错误:1054,SQLState:42S22 2019-05-31 13:18:09错误[http-nio-8080-exec-5] o.h.e.j.s.SqlExceptionHelper:131-'字段列表'中的未知列'a'
看起来像是弹簧数据,其自动生成的数据中使用了非法列“ a” 选择子句