sql - Spring Data JPA Native Query Pagination Doesn't work on 2nd Page -
i using pagination on native query (sql server) works on initial page request, page 0, fails invalid column name when try results 2nd page. generated query works in ssms not in spring.
any insight appreciated.
here error:
hibernate: /* dynamic native sql query */ query (select inner_query.*, row_number() on ( order current_timestamp) __hibernate_row_nr__ ( select top(?) p.productkey page0_, p.productname page1_, p.sku page2_, p.materialkey page3_, p.mfgitemnumber page4_, p.packagesize page5_, p.priceuom page6_, p.casepack page7_, p.productdescription page8_, p.mediadomain page9_, p.imagepath page10_, p.imagename page11_, plp.price page12_, plp.listprice page13_, p.searchtext page14_ [dbo].[bdmproductcategory] pc inner join [dbo].bdmproduct p on pc.productkey = p.productkey inner join [dbo].bdmpricelistproduct plp on plp.productkey = p.productkey pc.categorykey = ? , pc.productkey > 0 , pc."delete" = 0 , plp.pricelistkey = ? -- #pageable order sku asc ) inner_query ) select page0_, page1_, page2_, page3_, page4_, page5_, page6_, page7_, page8_, page9_, page10_, page11_, page12_, page13_, page14_ query __hibernate_row_nr__ >= ? , __hibernate_row_nr__ < ? 2017-08-18 08:47:45.844 trace 19316 --- [nio-6193-exec-2] o.h.type.descriptor.sql.basicbinder : binding parameter [2] [bigint] - [4143] 2017-08-18 08:47:45.845 trace 19316 --- [nio-6193-exec-2] o.h.type.descriptor.sql.basicbinder : binding parameter [3] [bigint] - [657] 2017-08-18 08:47:45.980 warn 19316 --- [nio-6193-exec-2] o.h.engine.jdbc.spi.sqlexceptionhelper : sql error: 0, sqlstate: s1093 2017-08-18 08:47:45.980 error 19316 --- [nio-6193-exec-2] o.h.engine.jdbc.spi.sqlexceptionhelper : column name productkey not valid. 2017-08-18 08:47:45.990 error 19316 --- [nio-6193-exec-2] o.a.c.c.c.[.[.[/].[dispatcherservlet] : servlet.service() servlet [dispatcherservlet] in context path [] threw exception [request processing failed; nested exception org.springframework.orm.jpa.jpasystemexception: not execute query; nested exception org.hibernate.exception.genericjdbcexception: not execute query] root cause com.microsoft.sqlserver.jdbc.sqlserverexception: column name productkey not valid.
here model:
@entity @table(name = "vw_bdmproductinfo") // view! public class bdmproductinfo { @id private long productkey; private long materialkey; private string sku; private bigdecimal price; private bigdecimal listprice; private string priceuom; private string casepack; private string packagesize; private string mfgitemnumber; private string productname; private string productdescription; private string mediadomain; private string imagepath; private string imagename; private string searchtext; protected bdmproductinfo() {}
....
here repository:
@restresource(path="findproductinfobycategory") @query(value="select p.productkey, p.productname, p.sku, p.materialkey, p.mfgitemnumber, p.packagesize, p.priceuom, p.casepack, p.productdescription, p.mediadomain, p.imagepath, p.imagename, plp.price, plp.listprice, p.searchtext " + "from [dbo].[bdmproductcategory] pc " + "inner join [dbo].bdmproduct p on pc.productkey = p.productkey " + "inner join [dbo].bdmpricelistproduct plp on plp.productkey = p.productkey " + "where pc.categorykey = :categorykey " + "and pc.productkey > 0 " + "and pc.\"delete\" = 0 " + "and plp.pricelistkey = :pricelistkey \n-- #pageable\n ", countquery="select count(*) " + "from [dbo].[bdmproductcategory] pc " + "inner join [dbo].bdmproduct p on pc.productkey = p.productkey " + "inner join [dbo].bdmpricelistproduct plp on plp.productkey = p.productkey " + "where pc.categorykey = :categorykey " + "and pc.productkey > 0 " + "and pc.\"delete\" = 0 " + "and plp.pricelistkey = :pricelistkey ",nativequery=true) page<bdmproductinfo> findproductinfobycategory(@param("categorykey") long categorykey, @param("pricelistkey") long pricelistkey, pageable pageable );
Comments
Post a Comment