英文:
spring jpa not able to locate the field when there are two consecutive capital letter coming in the same field name of a query method
问题
方法名中包含两个连续的大写字母在同一个字段名中时,spring-jpa 无法在表中定位相同的字段。
查询方法示例:
-
findByTypeAndASiteNameOrTypeAndZSiteName
-
findByAColumnOrBColumn
以上查询方法解释:
- (type AND a_site_name) 或 (type AND z_site_name)
- a_column 或 b_column
同样的查询方法在 spring boot 和 spring-data-jpa 的 2.1.7.RELEASE 版本中是正常工作的。目前,我正在迁移到 2.2.5.RELEASE 版本,但我遇到了问题。
异常信息:
无法在此 ManagedType [com.example.h2demo.domain.Subscriber] 上找到具有给定名称 [ASiteName] 的属性。
英文:
When the method name contains two consecutive capital letters in the same field name, the spring-jpa is not able to locate the same field in the table
Examples query method:
1.findByTypeAndASiteNameOrTypeAndZSiteName
2.findByAColumnOrBColumn
The above query method explanation
- (type AND a_site_name) or (type AND z_site_name)
- a_column or b_column
The same query method was working up to 2.1.7.RELEASE of spring boot and spring-data-jpa. Currently, I am migrating to 2.2.5.RELEASE and I am facing the issue.
Exception:
Unable to locate Attribute with the the given name [ASiteName] on this ManagedType [com.example.h2demo.domain.Subscriber]
答案1
得分: 1
这从Spring Boot 2.1.8变更为2.1.9。
根据Java Beans规范,aColumn的getter和setter必须是:
public String getaColumn()
public void setaColumn(String aColumn)
因此查询方法必须是:
findByaColumnOrbColumn
在Spring Data JPA的JIRA中了解更多信息:
https://jira.spring.io/browse/DATACMNS-1589
英文:
This has changed from Spring Boot 2.1.8 to 2.1.9
According to the Java Beans specification the getter and setter for aColumn must be:
public String getaColumn
public void setaColumn(String aColumn)
So the query method must be:
findByaColumnOrbColumn
Read more about this in the JIRA of Spring Data JPA
https://jira.spring.io/browse/DATACMNS-1589
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论