Repository navigation
fix(hibernate5): honour length on the id in MappingBuilder.orm - #16987
borinquenkid wants to merge 4 commits into
Conversation
Mapping.id(Map) bound the map to Identity, which has no length, so the value was dropped and the id column stayed VARCHAR(255). The length now goes to the id column the way the mapping closure form already did. Fixes #14497 Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL
jamesfredley
left a comment
There was a problem hiding this comment.
Not approving. A length on the id is copied. A wildcard default, such as a SQL type for every column, is dropped for that id.
Answers the review of #16987: the id config started blank, which stopped the fallback to the '*' defaults, so an id with a length lost the wildcard SQL type. It now starts from the wildcard defaults, as every other property does, and the length is set on that column. Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL
|
Answers the wildcard point (
Not tried: a wildcard that sets a column name, which would also have to reach the id. |
jamesfredley
left a comment
There was a problem hiding this comment.
Requested changes. A later column declaration for the id no longer merges into the column this length created, so the identifier has two columns.
…s length made
id generator: 'assigned', length: 20 followed by property('id') { column { name 'custom_id' } } gave the id two columns, and
mapping validation failed. The length sizes the id column the mapping builder keeps for it, and marked that column as taken, so
the column a later declaration makes was added beside it. The column a length creates, or takes over from the wildcard defaults,
is now left open to the next declaration, as a copy of the defaults is, so the identifier keeps one column, in either order.
IdentityLengthSpec gains rows for the length before and after the declaration, with a wildcard SQL type, and for a declaration
that gives no name.
Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL
|
Thank you, that was a real gap. The length sizes the id column the mapping builder keeps for the identifier, and it marked that column as taken, so the column a later declaration makes ( The column that a length creates, or takes over from the wildcard defaults, is now left open to the next declaration, as a copy of the defaults is, so the identifier keeps one column. I checked both orders, because the same gap could have shown the other way round: with the length after the declaration, the id also keeps one column, the length being set on the column the declaration made.
|
jamesfredley
left a comment
There was a problem hiding this comment.
The items this review found have been addressed. A later declaration of the id fills in the column its length made, and the length stays.
The 7.0.x patch line takes no more fixes after the 2026-11-25 releases; this PR moves to 7.2.x. Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL
|
Moved to 7.2.x: after the 2026-11-25 releases the 7.x line takes fixes on 7.2.x only. The branch has 7.2.x merged in and its module tests and codeStyle pass on it. Nothing else changed, so the review so far still applies; a fresh approval on the new head is needed for the merge rule. |
✅ All tests passed ✅Test SummaryTip Inspect all details with the TestLens CLI: CI / Functional Tests (Java 17, indy=false) > :grails-test-examples-datasources:integrationTest
CI / Functional Tests (Java 21, indy=false) > :grails-test-examples-datasources:integrationTest
🏷️ Commit: 2e9aa68 Test FailuresOsivRequestSessionSpec > a task a request returns lazily loads associations of the entities its action loaded (:grails-test-examples-datasources:integrationTest in CI / Functional Tests (Java 17, indy=false) | Attempt 1/3)OsivRequestSessionSpec > a task a request returns lazily loads associations of the entities its action loaded (:grails-test-examples-datasources:integrationTest in CI / Functional Tests (Java 21, indy=false) | Attempt 2/3)OsivRequestSessionSpec > a task a request returns lazily loads associations of the entities its action loaded (:grails-test-examples-datasources:integrationTest in CI / Functional Tests (Java 21, indy=false) | Attempt 1/3)Learn more about TestLens at testlens.app/docs. |
sbglasius
left a comment
There was a problem hiding this comment.
This is an AI assisted review
The length now reaches the id column, and later id declarations fill in that same column. CI skipped the tests here; a run ci label would confirm IdentityLengthSpec. LGTM.
Mapping.id(Map)bound the map toIdentity, which has nolength, soid generator: 'assigned', length: 20insideMappingBuilder.ormwas dropped and the id column stayedVARCHAR(255). The length now goes to the id column, the way the plain mapping closure already did.Verified locally: the new
IdentityLengthSpecreads the column length from the schema; theMappingBuilder.ormfeature fails (255) without the change and passes with it, and the mapping closure feature passes before and after. CodeNarc is clean. Hibernate 7 has the same gap inHibernateSimpleIdentityon 8.0.x, which a separate PR will cover.Fixes #14497
https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL