如何解决奇怪的行为[Spring Boot Upgrade 2.2.2]正在获取java.lang.NullPointerException:org.hibernate.loader.custom.sql.NamedParamBinder.bind
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为空,名称=“ eXcelProcessstatus”
我已经正确拼写了 eXcelProcessstatus ,因为它在数据库表和我的Entity类中
下面是
中的值qp.getNamedParameters()
{documentProcessstatus=PROCESSED,clientID=1,isDeleted=0,similarityProcessstatus=nopROCESS,siteID=3}
它不包含 eXcelProcessstatus
,我不确定这是否与 eXcelProcessstatus
更多发现。
我也曾尝试降低@param(name=excelProcessstatus)
中的X,但仍然出现相同的错误。
休眠版本:
hibernate-core-5.4.20.Final.jar
hibernate-validator-6.1.5.Final.jar
hibernate-commons-annotations-5.1.0.Final.jar
hibernate-c3p0-5.4.21.Final.jar
解决方法
不确定这是否是由于升级引起的,但是在查询中进行了以下更改(这是一个巨大的更改)[空格]
代替
(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);
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。