Spring数据传递给setFirstResult的负值

时间:2017-02-01 17:05:33

标签: java spring spring-boot spring-data

我有一个简单的PagingAndSortingRepository,包含Spring数据和这样的查询:

public List<VhSequenceEntity> findByCampaignIdAndOrganizationId(
        @Param("campaignId") Long campaignId, @Param("organizationId") Long organizationId, Pageable pageable);

当我将它与单页查询一起使用时,它可以正确获取信息,但当分页信息发生变化时,我有以下错误:

org.springframework.dao.InvalidDataAccessApiUsageException: Negative value (-727379968) passed to setFirstResult; nested exception is java.lang.IllegalArgumentException: Negative value (-727379968) passed to setFirstResult
at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:384)
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:246)
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.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:133)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
at com.sun.proxy.$Proxy107.findByCampaignIdAndOrganizationId(Unknown Source)

我搜索了此错误,但结果与我执行的流程无关。

谢谢!

1 个答案:

答案 0 :(得分:0)

更改分页信息时,我为页面参数设置了一个太大的值。因此,如果您收到此错误,请确保为可分页对象中的每个参数设置正确的值。