奇怪的行为[Spring boot upgrade 2.2.2]在org.hubinate.loader.custom.


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)

我在将Spring Boot从1.5.x升级到2.2.2后收到了上述错误。我相信这也升级了Hibernate版本,这可能会导致上述错误。我不确定这是否是Hibernate 中的错误

我是否应该通过在gradle中指定来降级我的Hibernate版本?而不是使用Spring Boot 2.2.2提供的默认版本?

这是Hibernate 5.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为null,name=";eXcelProcessStatus";

我已经正确拼写了eXcelProcessStatus,因为它在数据库表和我的实体类中

以下是中的值

qp.getNamedParameters()
{documentProcessStatus=PROCESSED, clientID=1, isDeleted=0, similarityProcessStatus=NOPROCESS, siteID=3}

它不包含eXcelProcessStatus,我不确定这是否与eXcelProcessStatus中的X(大写(有关

更多发现

我也尝试过降低@param(name=excelProcessStatus)中的X,但仍然会出现同样的错误。

Hibernate版本
Hibernate-core-5.4.20.Final.jar
Hibernate-validator-6.1.5.Final.jar
hibinate-commons-annotations-5..1.0.Final.jar
Hibernate-c3p0-5.4.21.Final.jar

不确定这是否是由于升级,但在查询中进行了以下更改(这是一个巨大的更改([space]

而不是

(hi.excelProcessStatus in:eXcelProcessStatus)

这样做(hi.excelProcessStatus in: eXcelProcessStatus)

已经解决了问题。问题似乎只是[space]

像这样的书写方法

@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);

相关内容

最新更新