Skip to content

Fix fully populated check in DataClassRowMapper for classes with setters - #37532

Merged
sbrannen merged 1 commit into
spring-projects:7.0.xfrom
namest504:rowmapper-suppressed-property-check
Oct 21, 2026
Merged

sbrannen merged 1 commit into
spring-projects:7.0.xfrom
namest504:rowmapper-suppressed-property-check

Conversation

@namest504

Copy link
Copy Markdown
Contributor

DataClassRowMapper suppresses the constructor parameters of the mapped class as bean properties via suppressProperty(), since they are populated through the constructor. However, suppressProperty() only removed the property from mappedProperties and not from mappedPropertyNames, which is the set compared against the populated properties when checkFullyPopulated is enabled.

As a result, for a class with an all-args constructor and setters for its constructor parameters, setCheckFullyPopulated(true) always failed with

InvalidDataAccessApiUsageException: Given ResultSet does not contain all properties
necessary to populate object of class ...: [balance, name, birthDate, age]

even though the ResultSet contained every column. Records are not affected since they have no setters.

This change removes a suppressed property from mappedPropertyNames as well, so the check only covers the properties that are actually populated via setters. Constructor parameters are still enforced through constructMappedInstance(), which fails for a missing column. The same code exists in 6.2.x and 7.0.x.

Note: #37329 touches mapRow() in BeanPropertyRowMapper as well, but a different part of it; this change is limited to suppressProperty().

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Oct 21, 2026
@sbrannen sbrannen added the in: data Issues in data modules (jdbc, orm, oxm, tx) label Oct 21, 2026
@sbrannen sbrannen self-assigned this Oct 21, 2026
@sbrannen sbrannen added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Oct 21, 2026
@sbrannen sbrannen added this to the 7.0.11 milestone Oct 21, 2026
DataClassRowMapper suppresses constructor parameters as bean
properties, but suppressProperty only removed them from the mapped
properties and not from the property names used by the fully
populated check. As a result, a data class with setters for its
constructor parameters always failed that check, even when the
ResultSet contained every column.

Closes spring-projectsgh-37532

Signed-off-by: Seungtaek Lim <namest504@gmail.com>
@sbrannen
sbrannen force-pushed the rowmapper-suppressed-property-check branch from c7e91c8 to 9fcdc1f Compare October 21, 2026 12:49
@sbrannen
sbrannen changed the base branch from main to 7.0.x October 21, 2026 12:49
@sbrannen sbrannen changed the title Exclude suppressed properties from fully populated check Exclude suppressed properties from fully populated check in BeanPropertyRowMapper Oct 21, 2026
@sbrannen sbrannen changed the title Exclude suppressed properties from fully populated check in BeanPropertyRowMapper Exclude suppressed properties from fully populated check in DataClassRowMapper Oct 21, 2026
@sbrannen sbrannen changed the title Exclude suppressed properties from fully populated check in DataClassRowMapper Fix fully populated check in DataClassRowMapper for classes with setters Oct 21, 2026
@sbrannen

Copy link
Copy Markdown
Member

Good catch! πŸ‘

Note that this is related to #26569 (see 4fe3ca1).

@sbrannen
sbrannen merged commit dcfc89b into spring-projects:7.0.x Oct 21, 2026
1 of 2 checks passed
@github-actions

This comment was marked as outdated.

sbrannen added a commit that referenced this pull request Oct 21, 2026
@sbrannen

Copy link
Copy Markdown
Member

This has been merged into 7.0.x and main in dcfc89b, and I simplified the tests in a041c99.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: data Issues in data modules (jdbc, orm, oxm, tx) type: bug A general bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants