Skip to content

Introspector.decapitalize cause attribute not found exception when parameter name starts with two uppercase letters [DATACMNS-1417] #1851

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Nov 5, 2018 · 2 comments
Assignees
Labels
has: design-decision An issue that contains a design decision about its topic in: mapping Mapping and conversion infrastructure

Comments

@spring-projects-issues
Copy link

horance opened DATACMNS-1417 and commented

The commit 5f87c67#diff-b9260ff138b656777898127d2fe03f02%C2%A0changes propertyName handling from StringUtils.uncapitalize(name) to Introspector.decapitalize(name), and it cause exception when the attribue name contain two uppercase letters at beginning.

Example:

 

public interface InebQuestionnaireQuestionRepository extends CrudRepository<InebQuestionnaireQuestionEntity, InebQuestionnaireQuestionEntityPk> {
    List<InebQuestionnaireQuestionEntity> findByTypeAndVCodeOrderByQCodeAsc(String type, String vCode);	
    List<InebQuestionnaireQuestionEntity> findByTypeAndVCodeAndStrategyCodeOrderByQCodeAsc(String type, String vCode, String strategyCode);
}

will cause exception:

Caused by: java.lang.IllegalArgumentException: Attribute "QCode" of any not found in com.ctbc.ebmw.business.robogo.repository.entities.InebQuestionnaireQuestionEntity
	at org.apache.openjpa.persistence.meta.AbstractManagedType.notFoundException(AbstractManagedType.java:741) ~[openjpa-2.4.2.jar:2.4.2]
	at org.apache.openjpa.persistence.meta.AbstractManagedType.getAttribute(AbstractManagedType.java:244) ~[openjpa-2.4.2.jar:2.4.2]
	at org.apache.openjpa.persistence.meta.AbstractManagedType.getAttribute(AbstractManagedType.java:468) ~[openjpa-2.4.2.jar:2.4.2]
	at org.springframework.data.jpa.repository.query.QueryUtils.toExpressionRecursively(QueryUtils.java:571) ~[spring-data-jpa-1.11.16.RELEASE.jar:na]
	at org.springframework.data.jpa.repository.query.QueryUtils.toJpaOrder(QueryUtils.java:548) ~[spring-data-jpa-1.11.16.RELEASE.jar:na]
	at org.springframework.data.jpa.repository.query.QueryUtils.toOrders(QueryUtils.java:501) ~[spring-data-jpa-1.11.16.RELEASE.jar:na]
	at org.springframework.data.jpa.repository.query.JpaQueryCreator.complete(JpaQueryCreator.java:195) ~[spring-data-jpa-1.11.16.RELEASE.jar:na]
	at org.springframework.data.jpa.repository.query.JpaQueryCreator.complete(JpaQueryCreator.java:143) ~[spring-data-jpa-1.11.16.RELEASE.jar:na]
	at org.springframework.data.jpa.repository.query.JpaQueryCreator.complete(JpaQueryCreator.java:52) ~[spring-data-jpa-1.11.16.RELEASE.jar:na]
	at org.springframework.data.repository.query.parser.AbstractQueryCreator.createQuery(AbstractQueryCreator.java:88) ~[spring-data-commons-1.13.16.RELEASE.jar:na]
	at org.springframework.data.repository.query.parser.AbstractQueryCreator.createQuery(AbstractQueryCreator.java:73) ~[spring-data-commons-1.13.16.RELEASE.jar:na]
	at org.springframework.data.jpa.repository.query.PartTreeJpaQuery$QueryPreparer.<init>(PartTreeJpaQuery.java:133) ~[spring-data-jpa-1.11.16.RELEASE.jar:na]
	at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:72) ~[spring-data-jpa-1.11.16.RELEASE.jar:na]
	... 52 common frames omitted

The same code fragment works fine on spring boot 1.5.13.RELEASE (spring-data-commons-1.3.12.RELEASE)

 

 


Affects: 1.13.16 (Ingalls SR16)

Reference URL: 5f87c67#diff-b9260ff138b656777898127d2fe03f02

@spring-projects-issues
Copy link
Author

horance commented

The attribue in entity class is :

 

@Id
@Column(name = "Q_CODE")
private String qCode;

@spring-projects-issues spring-projects-issues added type: bug A general bug in: mapping Mapping and conversion infrastructure labels Dec 30, 2020
@mp911de mp911de added for: team-attention An issue we need to discuss as a team to make progress status: waiting-for-triage An issue we've not yet triaged and removed type: bug A general bug labels Sep 14, 2023
@mp911de mp911de assigned mp911de and unassigned odrotbohm Sep 18, 2023
@mp911de mp911de removed the for: team-attention An issue we need to discuss as a team to make progress label Sep 18, 2023
christophstrobl added a commit that referenced this issue Nov 21, 2023
@christophstrobl christophstrobl added this to the 3.3 M1 (2024.0.0) milestone Nov 21, 2023
@christophstrobl christophstrobl added has: design-decision An issue that contains a design decision about its topic and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 21, 2023
@christophstrobl
Copy link
Member

The path resolution should always favour properties that can be directly discovered on a given type over any potential nested path.
In summary the requested change will alter the behaviour of the property lookup to follow this rule.

1. No ambiguity - property name

record Container(String qCode)

Before: the field would not be discovered.
After: the path points to the qCode property.

2. No ambiguity - property path

record Container(Code q)
record Code(String code)

Before: the path points to q.code.
After: the path points to q.code.

3. Ambiguity path vs property

record Container(String qCode, Code q)
record Code(String code)

Before: the path points to q.code.
After: the path points to the qCode property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has: design-decision An issue that contains a design decision about its topic in: mapping Mapping and conversion infrastructure
Projects
None yet
4 participants