奇怪的行为[spring boot upgrade 2.2.2]获取java.lang.nullpointerexception:null位于org.hibernate.loader.custom.sql.namedparambinder.bind

yzxexxkh  于 2021-06-30  发布在  Java
关注(0)|答案(1)|浏览(369)
java.lang.NullPointerException: null
    at org.hibernate.loader.custom.sql.NamedParamBinder.bind(NamedParamBinder.java:34)
    at org.hibernate.loader.custom.CustomLoader.bindParameterValues(CustomLoader.java:475)
    at org.hibernate.loader.Loader.bindPreparedStatement(Loader.java:2169)
    at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2146)
    at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2078)
    at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2056)
    at org.hibernate.loader.Loader.doQuery(Loader.java:953)
    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:350)
    at org.hibernate.loader.Loader.doList(Loader.java:2887)
    at org.hibernate.loader.Loader.doList(Loader.java:2869)
    at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2701)
    at org.hibernate.loader.Loader.list(Loader.java:2696)
    at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:338)
    at org.hibernate.internal.SessionImpl.listCustomQuery(SessionImpl.java:2142)
    at org.hibernate.internal.AbstractSharedSessionContract.list(AbstractSharedSessionContract.java:1163)
    at org.hibernate.query.internal.NativeQueryImpl.doList(NativeQueryImpl.java:173)
    at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1533)
    at org.hibernate.query.Query.getResultList(Query.java:165)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.orm.jpa.SharedEntityManagerCreator$DeferredQueryInvocationHandler.invoke(SharedEntityManagerCreator.java:409)
    at com.sun.proxy.$Proxy292.getResultList(Unknown Source)
    at org.springframework.data.jpa.repository.query.JpaQueryExecution$CollectionExecution.doExecute(JpaQueryExecution.java:126)
    at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:88)
    at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:154)
    at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:142)
    at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor$QueryMethodInvoker.invoke(QueryExecutorMethodInterceptor.java:195)
    at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:152)
    at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:130)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:149)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)

在将SpringBoot从1.5.x升级到2.2.2之后,我遇到了上述错误。我相信这也升级了hibernate版本,这可能会导致上述错误。我不确定这是不是冬眠中的虫子
我应该通过在gradle中指定来降级我的hibernate版本吗?而不是使用SpringBoot2.2.2提供的默认版本?
这是Hibernate5.x中的缺陷吗?
程序启动成功。它给出程序试图执行本机查询时的错误;语法如下所示

@Query(value = " SELECT ds.* FROM DocumentSimilarity AS ds INNER JOIN CompanyDocumentInfo AS hi ON hi.companyDocumentInfoID = ds.companyDocumentInfoID AND hi.isDeleted=:isDeleted AND hi.siteID=:siteID AND hi.clientID=:clientID  " +
            "WHERE        (ds.processStatus =:documentProcessStatus) AND (hi.processStatus =:similarityProcessStatus) AND (hi.excelProcessStatus in:eXcelProcessStatus) order by ds.modifiedDate /*#pageable*/", countQuery = "select count(modifiedDate) from DocumentSimilarity order by modifiedDate /*#pageable*/ ", nativeQuery = true)
    List<DocumentSimilarity> getSimilarityRecordForExcel(@Param("clientID") int clientID, @Param("siteID") String siteID, @Param("documentProcessStatus") String documentProcessStatus, @Param("isDeleted") int isDeleted, @Param("eXcelProcessStatus") List<String> excelProcessStatus, @Param("similarityProcessStatus") String similarityProcessStatus, Pageable pageable);

调查结果
当它试图在下面执行时

final TypedValue typedValue = qp.getNamedParameters().get( name );
typedValue.getType().nullSafeSet( statement, typedValue.getValue(), position, session );

typedvalue为空,name=“excelprocessstatus”
我已经正确拼写了excelprocessstatus,因为它在数据库表和实体类中
下面是中的值

qp.getNamedParameters()

{documentProcessStatus=PROCESSED, clientID=1, isDeleted=0, similarityProcessStatus=NOPROCESS, siteID=3}

它不包含 eXcelProcessStatus ,我不确定这是否与中的x(大写)有关 eXcelProcessStatus 更多发现。
我也试过把x降下来 @param(name=excelProcessStatus) ,但我仍然得到相同的错误。
休眠版本:
hibernate-core-5.4.20.final.jar
hibernate-validator-6.1.5.final.jar
hibernate-commons-annotations-5.1.0.final.jar
休眠-c3p0-5.4.21.final.jar

sqougxex

sqougxex1#

不确定这是否是由于升级导致的,但是在查询中做了以下更改(这是一个巨大的更改)[space]
而不是 (hi.excelProcessStatus in:eXcelProcessStatus) 这样做 (hi.excelProcessStatus in: eXcelProcessStatus) 解决了问题。问题似乎只是[空间]。
这样的写作方法

@Query(value = " SELECT ds.* FROM DocumentSimilarity AS ds INNER JOIN CompanyDocumentInfo AS hi ON hi.companyDocumentInfoID = ds.companyDocumentInfoID AND hi.isDeleted=:isDeleted AND hi.siteID=:siteID AND hi.clientID=:clientID  " +
            "WHERE        (ds.processStatus =:documentProcessStatus) AND (hi.processStatus =:similarityProcessStatus) AND (hi.excelProcessStatus in: eXcelProcessStatus) order by ds.modifiedDate /*#pageable*/", countQuery = "select count(modifiedDate) from DocumentSimilarity order by modifiedDate /*#pageable*/ ", nativeQuery = true)
    List<DocumentSimilarity> getSimilarityRecordForExcel(@Param("clientID") int clientID, @Param("siteID") String siteID, @Param("documentProcessStatus") String documentProcessStatus, @Param("isDeleted") int isDeleted, @Param("eXcelProcessStatus") List<String> excelProcessStatus, @Param("similarityProcessStatus") String similarityProcessStatus, Pageable pageable);

相关问题