将Spring引导版本从1.3.5升级到1.4.2后,似乎是DB2ZOS方言在Spring JPA中的分页查询不起作用。 我正在使用Spring JPA和DB2,当我使用分页存储库和查询第二页时,它会抛出错误。这是生成的查询。
select
*
from
( select
inner2_.*,
rownumber() over(
order by
order of inner2_) as rownumber_ from
( select
componentd0_.comp_data_field_st_msg_id as comp_dat1_0_,
componentd0_.comp_data_file_id as comp_dat5_0_,
componentd0_.comp_data_file_field_id as comp_dat6_0_,
componentd0_.component_serial_no as componen2_0_,
componentd0_.controller_short_name as controll3_0_,
componentd0_.message as message4_0_
from
cs_comp_data_field_st_msg componentd0_
left outer join
cs_comp_data_file componentd1_
on componentd0_.comp_data_file_id=componentd1_.comp_data_file_id
where
componentd1_.comp_data_file_id=?
order by
componentd0_.comp_data_field_st_msg_id asc fetch first 50 rows only ) as inner2_ ) as inner1_
where
rownumber_ > 25
order by
rownumber_
o.h.engine.jdbc.spi.SqlExceptionHelper : DB2 SQL Error: SQLCODE=-199, SQLSTATE=42601, SQLERRMC=OF;??( [ DESC ASC NULLS RANGE CONCAT || / MICROSECONDS MICROSECOND, DRIVER=3.69.24
2016-12-26 13:41:42.886 ERROR [componentdatafiles,c50b4d59a68eb961,c50b4d59a68eb961,false] AK51602 20296 --- [io-8081-exec-75] o.h.engine.jdbc.spi.SqlExceptionHelper : DB2 SQL Error: SQLCODE=-516, SQLSTATE=26501, SQLERRMC=null, DRIVER=3.69.24
2016-12-26 13:41:42.887 ERROR [componentdatafiles,c50b4d59a68eb961,c50b4d59a68eb961,false] AK51602 20296 --- [io-8081-exec-75] o.h.engine.jdbc.spi.SqlExceptionHelper : DB2 SQL Error: SQLCODE=-514, SQLSTATE=26501, SQLERRMC=SQL_CURLH200C1, DRIVER=3.69.24
2016-12-26 13:41:42.918 DEBUG [componentdatafiles,c50b4d59a68eb961,c50b4d59a68eb961,false] AK51602 20296 --- [io-8081-exec-75] c.d.c.n.service.NonDeereXmlServiceImpl : Critical system error
org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:261)
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:244)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:491)
at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:59)
at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:147)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.data.jpa.repository.support.CrudMethodMeta
答案 0 :(得分:0)
org.hibernate.dialect.DB2Dialect
类生成无效查询,说明其失败的原因。我已经覆盖了方言中的getLimit
函数并将其解析。