我在数据库中拥有数千条记录。我想在春天使用分页显示记录。我能够获取第一组数据,但在获取第二组数据时,我正面临着这个问题。
我正在使用spring boot 1.5.8 Release和DB2数据库版本11以及带有驱动程序版本4.23的平台Z / OS
我尝试使用自定义方言也基于参考: Issue with Spring data jpa Db2 pagination
但我仍面临同样的问题。你能帮我解决这个问题。
下面给出了详细信息:
application.properties:
spring.jpa.properties.hibernate.dialect=com.test.batch.DB2ZOSDialect
DB2ZOSDialect.java:
import org.hibernate.dialect.DB2Dialect;
public class DB2ZOSDialect extends DB2Dialect {
@Override
public boolean supportsSequences() {
return true;
}
@Override
public String getSequenceNextValString(String sequenceName) {
return "select nextval for " + sequenceName + " from sysibm.sysdummy1";
}
@Override
public String getCreateSequenceString(String sequenceName) {
return "create sequence " + sequenceName + " as integer start with 1 increment by 1 minvalue 1 nomaxvalue nocycle nocache"; //simple default settings..
}
@Override
public String getDropSequenceString(String sequenceName) {
return "drop sequence " + sequenceName + " restrict";
}
@Override
public String getQuerySequencesString() {
return "select name from sysibm.syssequences";
}
@Override
public String getForUpdateString() {
return " WITH RS USE AND KEEP EXCLUSIVE LOCKS";
}
}
服务:
public void fetchDetails() {
for(int pageCount=0; pageCount < pageTotalCount; pageCount++) {
Page<com.test.Item> db2Data = db2Repository
.findByIdIn(new ArrayList<Integer>(Constant.LIST), new PageRequest(pageCount, 10));
System.out.println("db2Data :"+db2Data.getContent().size());
}
}
错误:
15:42:28,990 INFO [stdout] (default task-2) Hibernate: select item0_.id as t1_1 from itm item0_ where item0_.id in (?) fetch first 10 rows only
db2Data :10
15:55:37,270 INFO [stdout] (default task-2) Hibernate: select * from ( select inner2_.*, rownumber() over(order by order of inner2_) as rownumber_ from ( select item0_.id as t1_1 from itm item0_ where item0_.id in (?) fetch first 20 rows only ) as inner2_ ) as inner1_ where rownumber_ > 10 order by rownumber_
15:55:37,744 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-2) SQL Error: -199, SQLState: 42601
15:55:37,746 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-2) DB2 SQL Error: SQLCODE=-199, SQLSTATE=42601, SQLERRMC=OF;;??( [ DESC ASC NULLS RANGE CONCAT || / MICROSECONDS MICROSECOND, DRIVER=4.18.60
15:55:37,747 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-2) SQL Error: -516, SQLState: 26501
15:55:37,748 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-2) DB2 SQL Error: SQLCODE=-516, SQLSTATE=26501, SQLERRMC=null, DRIVER=4.18.60
15:55:37,749 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-2) SQL Error: -514, SQLState: 26501
15:55:37,749 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-2) DB2 SQL Error: SQLCODE=-514, SQLSTATE=26501, SQLERRMC=SQL_CURLN200C1, DRIVER=4.18.60
15:55:40,031 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-2) SQL Warning Code: 4223, SQLState: null
15:55:40,031 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-2) Origination unknown: [10228][11541][4.18.60] Security exceptions occurred while loading driver. ERRORCODE=4223, SQLSTATE=null
15:55:40,049 INFO [stdout] (default task-2) 2017-12-14 15:55:40{EST} [default task-2] ERROR o.s.boot.web.support.ErrorPageFilter - Forwarding to error page from request [/copyAllItem] due to exception [could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet]
15:55:40,049 INFO [stdout] (default task-2) org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet
15:55:40,049 INFO [stdout] (default task-2) at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:261)
15:55:40,049 INFO [stdout] (default task-2) at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:244)
15:55:40,049 INFO [stdout] (default task-2) at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:488)
15:55:40,049 INFO [stdout] (default task-2) at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:59)
15:55:40,049 INFO [stdout] (default task-2) at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213)
15:55:40,049 INFO [stdout] (default task-2) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:147)
15:55:40,049 INFO [stdout] (default task-2) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
15:55:40,049 INFO [stdout] (default task-2) at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:133)
15:55:40,049 INFO [stdout] (default task-2) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
15:55:40,049 INFO [stdout] (default task-2) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
15:55:40,049 INFO [stdout] (default task-2) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
15:55:40,049 INFO [stdout] (default task-2) at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:57)
15:55:40,049 INFO [stdout] (default task-2) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
15:55:40,049 INFO [stdout] (default task-2) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
15:55:40,049 INFO [stdout] (default task-2) at com.sun.proxy.$Proxy281.findByIdIn(Unknown Source)
15:55:40,049 INFO [stdout] (default task-2) at com.test.ItemServiceImpl.copyAllItem(ItemServiceImpl.java:308)
15:55:40,050 INFO [stdout] (default task-2) at com.test.ItemController.copyAllItem(ItemController.java:70)
15:55:40,050 INFO [stdout] (default task-2) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)