SpringDataJPA + SQL Server 分页查询返回page0_字段
2020-12-18 19:34:07 852
在配置了方言后, 使用 jpa 的分页查询(Pageable)时, sql返回的字段都变成了这样
{
"page1_": "2020121800040029834",
"page2_": 19.25,
"page3_": null,
"page0_": "2020-12-18 19:15:13"
}
分析jpa hibernate发出的sql后, 发现select的字段都被设置了别名
temp.oper_time AS page0_,
od_no AS page1_,
qt_amount AS page2_,
num AS page3_
于是将查询sql手动设置对应的别名
temp.oper_time AS oper_time,
od_no AS od_no,
qt_amount AS qt_amount,
num AS num
再次查询, 字段名称正确
{
"oper_time": "2020-12-18 19:15:13",
"od_no": "2020121800040029834",
"qt_amount": 19.25,
"num": null
}