Skip to content

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

Closed
@spring-projects-issues

Description

@spring-projects-issues

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

Metadata

Metadata

Assignees

Labels

has: design-decisionAn issue that contains a design decision about its topicin: mappingMapping and conversion infrastructure

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions