Spring boot [Spring boot迁移到2.3.3]InvalidDataAccessApiUsageException:用于名为..的查询。。您需要使用“提供名称”。使用@Param进行查询

Spring boot [Spring boot迁移到2.3.3]InvalidDataAccessApiUsageException:用于名为..的查询。。您需要使用“提供名称”。使用@Param进行查询,spring-boot,hibernate,jpa,spring-data-jpa,spring-data,Spring Boot,Hibernate,Jpa,Spring Data Jpa,Spring Data,将spring boot从1.x升级到2.2.2后,出现以下错误,这本身也升级了Hibernate 对于具有命名参数的查询,需要使用“为方法参数提供名称”。使用@Param作为查询方法参数,或者在Java8+上使用javac标志-parameters。;嵌套异常是java.lang.IllegalStateException:对于具有命名参数的查询,您需要为方法参数提供名称。使用@Param作为查询方法参数,或者在Java8+上使用javac标志-parameters 错误跟踪。 org.sp

将spring boot从1.x升级到2.2.2后,出现以下错误,这本身也升级了Hibernate

对于具有命名参数的查询,需要使用“为方法参数提供名称”。使用@Param作为查询方法参数,或者在Java8+上使用javac标志-parameters。;嵌套异常是java.lang.IllegalStateException:对于具有命名参数的查询,您需要为方法参数提供名称。使用@Param作为查询方法参数,或者在Java8+上使用javac标志-parameters

错误跟踪。


org.springframework.dao.InvalidDataAccessApiUsageException: For queries with named parameters you need to use provide names for method parameters. Use @Param for query method parameters, or when on Java 8+ use the javac flag -parameters.; nested exception is java.lang.IllegalStateException: For queries with named parameters you need to use provide names for method parameters. Use @Param for query method parameters, or when on Java 8+ use the javac flag -parameters.
    at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:371)
    at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:257)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:528)
    at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:61)
    at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:242)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:153)
    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)
    at 

带查询的方法声明

@Query(value = "select * from DocumentInfo where ClientID=:clientID and siteID=:siteID  and processStatus=:processStatus and eXcelProcessStatus=:eXcelProcessStatus order by modifiedDate asc /*#pageable*/ ", countQuery = "select count(*) from DocumentInfo order by DocumentInfoID /*#pageable*/ ", nativeQuery = true)
    List<DocumentInfo> findByClientIDAndSiteIDAndProcessStatusAndeXcelProcessStatusOrderByModifiedDateAsc(int clientID, String siteID, String processStatus, String eXcelProcessStatus, Pageable p);
我没有使用本机查询,它仍然说请使用@Param,它在早期版本的hibernate中没有指定@Param

编辑2


问题似乎在于Spring数据jpa,而不是hibernate/

如果您使用的是Maven,请尝试将其添加到pom.xml中的依赖项中:

<dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.3.0.Final</version>
        </dependency>

@ViralKondhia你还有同样的例外吗?@14239812是的,同样exception@ViralKondhia您介意在控制器上添加您的方法吗?@14239812 Controller?我使用的是SpringJPA,如果你是说存储库方法,那么它已经添加了。(这里有两个例子。)@ViralKondhia要使它正常工作,还应该有控制器和服务类。至少这是建议的格式。您可以在此链接上查看已批准的答案,以便更好地理解:
<dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.3.0.Final</version>
        </dependency>
<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.3.RELEASE</version>
        <relativePath />
    </parent>
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true