Spring数据jpa Db2分页问题

时间:2016-10-23 04:25:39

标签: spring db2

我正在使用Spring JPA和DB2,当我使用分页存储库和查询第二页时,它会抛出错误。 这是生成的查询

SELECT * 
FROM   (SELECT inner2_.*, 
               ROWNUMBER() 
                 OVER( 
                   ORDER BY ORDER OF inner2_) AS rownumber_ 
        FROM   (SELECT db2DATAa0_.c_type AS col_0_0_, 
                       db2DATAa0_.h_proc AS col_1_0_, 
                       db2DATAa0_.n_vin  AS col_2_0_, 
                       db2DATAa0_.i_cust AS col_3_0_ 
                FROM   dcu.v_rpt_data_hist db2DATAa0_ 
                WHERE  db2DATAa0_.reportid = '0H000488089' 
                       AND ( db2DATAa0_.c_type = 'S' 
                              OR db2DATAa0_.c_type = 'N' 
                              OR db2DATAa0_.c_type = 'A' 
                              OR db2DATAa0_.c_type = 'T' ) 
                ORDER  BY db2DATAa0_.h_proc desc 
                FETCH first 30 ROWS only) AS inner2_) AS inner1_ 
WHERE  rownumber_ > 15 
ORDER  BY rownumber_ 
  

Error: 2719372 [2016-10-21 16:29:02,040] [RxCachedThreadScheduler-13] WARN org.hibern ate.engine.jdbc.spi.SqlExceptionHelper - SQL Error: -199, SQLState: 42601 2719379 [2016-10-21 16:29:02,047] [RxCachedThreadScheduler-13] ERROR org.hibern ate.engine.jdbc.spi.SqlExceptionHelper - DB2 SQL Error: SQLCODE=-199, SQLSTATE= 42601, SQLERRMC=OF;??( [ DESC ASC NULLS RANGE CONCAT || / MICROSECONDS MICROSECO ND, DRIVER=3.57.82

有什么想法吗?

2 个答案:

答案 0 :(得分:0)

您的错误说明非法使用关键字。忘记了[DESC ASC NULLS RANGE CONCAT]。

我认为这是查询的关键部分:

ORDER BY ORDER OF inner2_

DB2期望第二个ORDER关键字之后的DESC,ASC,NULLS,RANGE,CONCAT之一。

答案 1 :(得分:0)

此问题可通过更改方言解决。 将配置或属性文件中的dialect更改为DB2ZOSDialect