gpt4 book ai didi

java - 将 spring-data-jpa 升级到 1.11.13.RELEASE order by throw 异常

转载 作者:太空宇宙 更新时间:2023-11-04 10:14:56 25 4
gpt4 key购买 nike

我将spring-data-jpa升级到1.11.13.RELEASE,因为此提交:https://github.com/spring-projects/spring-data-commons/commit/5f87c6766863072d761cb02f278b13c8631e655f ,

这个方法:

List<AppVersion> findByDeviceAndPlatformAndIVersionGreaterThanOrderByIVersionDesc(Device device,App app,Integer versioncode);

order by 找不到该属性,这是属性:

private Integer iVersion;

抛出此异常:

Caused by: java.lang.IllegalArgumentException:
Unable to locate Attribute with the the given name [IVersion] on this
ManagedType [cn.com.open.entity.BaseEntityRoot] at
org.hibernate.metamodel.internal.AbstractManagedType.checkNotNull(AbstractManageType.java:128)
at
org.hibernate.metamodel.internal.AbstractManagedType.getAttribute(AbstractManagedType.java:113)
at
org.hibernate.metamodel.internal.AbstractManagedType.getAttribute(AbstractManagedType.java:111)
at
org.hibernate.metamodel.internal.AbstractManagedType.getAttribute(AbstractManagedType.java:111)
at
org.springframework.data.jpa.repository.query.QueryUtils.toExpressionRecursively(QueryUtils.java:571)
at
org.springframework.data.jpa.repository.query.QueryUtils.toJpaOrder(QueryUtils.java:548)
at
org.springframework.data.jpa.repository.query.QueryUtils.toOrders(QueryUtils.java:501)
at
org.springframework.data.jpa.repository.query.JpaQueryCreator.complete(JpaQueryCreator.java:195)
at
org.springframework.data.jpa.repository.query.JpaQueryCreator.complete(JpaQueryCreator.java:143)
at
org.springframework.data.jpa.repository.query.JpaQueryCreator.complete(JpaQueryCreator.java:52)
at
org.springframework.data.repository.query.parser.AbstractQueryCreator.createQuery(AbstractQueryCreator.java:88)
at
org.springframework.data.repository.query.parser.AbstractQueryCreator.createQuery(AbstractQueryCreator.java:73)
at
org.springframework.data.jpa.repository.query.PartTreeJpaQuery$QueryPreparer.<init>(PartTreeJpaQuery.java:133)
at
org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:72)
... 52 common frames omitted

最佳答案

当属性的第二个字符为大写时,这是解析 OrderBy 子句时的错误。

您应该使用 Spring Data JPA 提交错误报告:

https://jira.spring.io/projects/DATAJPA/issues/DATAJPA-1397?filter=allopenissues

同时,您必须更改属性的名称或在 @Query 注释中编写查询。

关于java - 将 spring-data-jpa 升级到 1.11.13.RELEASE order by throw 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51838126/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com