Skip to content

fix(hibernate5): apply maxSize and type text to Map, List and Set element columns - #16923

Closed
borinquenkid wants to merge 3 commits into
7.2.xfrom
fix/h5-map-element-column-7.0.x
Closed

borinquenkid wants to merge 3 commits into
7.2.xfrom
fix/h5-map-element-column-7.0.x

Conversation

@borinquenkid

@borinquenkid borinquenkid commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Hibernate 5 counterpart of #16922 (8.0.x), for #16897.

Problem

  • Mapping type: 'text' on a basic collection (Map, List or Set of simple values) failed metadata build with user collection type class not found: text, because the type name was passed to Hibernate as a user collection type.

Change

  • CollectionType.getTypeName returns null for basic collections, so the mapped type is no longer treated as a collection type class.
  • maxSize and inList do not size the element column. For a collection, maxSize is the number of its elements and inList lists whole collections, so a List of String with maxSize: 2 is valid with one element of any length.

Tests

  • MapElementColumnSpec: default length, maxSize leaving the element length alone, type: 'text' on Map and List, an inList of lists, a list within maxSize that is saved, the join column name, and the unchanged key column.
  • H5 core suite: 696 tests, 0 failures.

Not covered

https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL

…ment columns

A mapped type: 'text' on a basic collection failed with "user collection
type class not found: text" because the type name was handed to Hibernate
as a user collection type. Basic collections no longer name a collection
type, and the element column now honors maxSize and inList.

Relates to #16897

Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@jamesfredley jamesfredley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not approving. A collection's maxSize now limits each element's length, and a collection inList whose allowed values are collections prevents startup.

@borinquenkid
borinquenkid requested a review from matrei November 12, 2026 14:12
…pe, not the length from maxSize or inList

The maxSize of a collection bounds the number of its elements, and its inList lists whole collections,
so neither is the length of an element. A List of String named body with maxSize 2 is valid with the
value ['abcdef'], because it has one element, and saving it failed on a varchar(2); an inList of
lists, such as [['abcdef']], was read as element strings and stopped the mapping from being built.
The column of the elements of a list, a set or a map is left to the type the mapping gives it: type
text is mapped as text, and the length stays what it was otherwise.

Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL
@borinquenkid

Copy link
Copy Markdown
Member Author

@jamesfredley Both are addressed in the new commit, and it removes the sizing from maxSize and inList altogether.

  • body maxSize: 2 with ['abcdef']. Reproduced: the list has one element, so validation passes, and the element column had been given the length 2, so saving failed. maxSize of a collection is its size. Neither maxSize nor inList gives the column of the elements a length any more, for a Map, a List or a Set. MapElementColumnSpec has a list within maxSize that is saved, and maxSize leaving the element length at the default for a map and a list; both fail without the change.
  • body inList: [['abcdef']] prevented startup. Reproduced: the allowed values of a collection are whole collections, and the length code read them as element strings (a cast to String, so a list could not be cast). The spec has an inList of lists on a list; the mapping builds and the column keeps its length.

What stays is the fix for type: 'text' on a basic collection, which is what #16897 asked for: it no longer fails the metadata build, and the elements are mapped as text. A length for the element column is not something maxSize can give, and joinTable: [column: ...] takes only a name today: a map there is turned into the column name and its length is ignored. I filed #17025 for both, with options. I also corrected the description of this PR, which still said that maxSize and inList size the column.

The Hibernate 5 module (696 tests) and codeStyle pass.

Branch policy: this commit adds no public type, no throw, and no schema change beyond the text type of the PR. Where the PR belongs is still open; I have not moved it.

If you find another shape that does not reproduce first time, a failing spec on a throwaway branch, or the few lines you ran, would help me a lot.

@borinquenkid

Copy link
Copy Markdown
Member Author

@jdaugherty: type: 'text' on a Map, List or Set of simple values failed the metadata build on Hibernate 5. Your read of the collection mapping would help.

@jamesfredley jamesfredley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The items this review found have been addressed. A collection's maxSize no longer limits each element, and an inList whose allowed values are collections no longer stops startup.

@borinquenkid
borinquenkid marked this pull request as draft November 26, 2026 00:58
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
@borinquenkid
borinquenkid changed the base branch from 7.0.x to 7.2.x November 26, 2026 02:38
@borinquenkid

Copy link
Copy Markdown
Member Author

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.

@borinquenkid
borinquenkid marked this pull request as ready for review November 26, 2026 02:38
@borinquenkid borinquenkid added run ci and removed no ci labels Nov 26, 2026
@borinquenkid
borinquenkid marked this pull request as draft November 26, 2026 06:17
@borinquenkid
borinquenkid marked this pull request as ready for review November 26, 2026 06:18
@testlens-app

testlens-app Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

✅ All tests passed ✅

⚠️ TestLens detected flakiness ⚠️

Test Summary

Tip

Inspect all details with the TestLens CLI: testlens pr 16923

CI / Functional Tests (Java 25, indy=false) > :grails-test-examples-datasources:integrationTest

Test Runs Flakiness
OsivRequestSessionSpec > a task a request returns lazily loads associations of the entities its action loaded ❌ ✅ 0% 🟢

🏷️ Commit: e11203d
▶️ Tests: 13454 executed
⚪️ Checks: 134/134 completed

Test Failures

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 25, indy=false) | Attempt 1/2)
Condition failed with Exception:

http('/requestSession/lazyVolumes?name=asynchronous').assertEquals(200, 'first,second')
|                                                     |
|                                                     org.opentest4j.AssertionFailedError: HTTP Status differs
|                                                     	at org.apache.grails.testing.http.client.TestHttpResponse.verify(TestHttpResponse.groovy:980)
|                                                     	at org.apache.grails.testing.http.client.TestHttpResponse.verifyStatus(TestHttpResponse.groovy:840)
|                                                     	at org.apache.grails.testing.http.client.TestHttpResponse.assertEquals(TestHttpResponse.groovy:580)
|                                                     	at functionaltests.OsivRequestSessionSpec.a task a request returns lazily loads associations of the entities its action loaded(OsivRequestSessionSpec.groovy:109)
<org.apache.grails.testing.http.client.TestHttpResponse@6147ff01 delegate=(GET http://localhost:46883/requestSession/lazyVolumes?name=asynchronous) 500 jsonSlurperConfig=org.apache.grails.testing.http.client.utils.JsonUtils$SlurperConfig(null, null, null, null, null) xmlSlurperConfig=org.apache.grails.testing.http.client.utils.XmlUtils$SlurperConfig@1d983b15>

	at functionaltests.OsivRequestSessionSpec.a task a request returns lazily loads associations of the entities its action loaded(OsivRequestSessionSpec.groovy:109)
Caused by: org.opentest4j.AssertionFailedError: HTTP Status differs
	at org.apache.grails.testing.http.client.TestHttpResponse.verify(TestHttpResponse.groovy:980)
	at org.apache.grails.testing.http.client.TestHttpResponse.verifyStatus(TestHttpResponse.groovy:840)
	at org.apache.grails.testing.http.client.TestHttpResponse.assertEquals(TestHttpResponse.groovy:580)
	... 1 more

Learn more about TestLens at testlens.app/docs.

@sbglasius sbglasius left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an AI assisted review

Skipping the collection type name for basic collections fixes type: 'text', and the spec pins maxSize/inList leaving the element column alone. The OsivRequestSessionSpec failure looks unrelated. LGTM.

@borinquenkid

Copy link
Copy Markdown
Member Author

Moved to 7.0.x as #17270: the bug is also on 7.0.x, the oldest branch with it. The change is rebuilt there on a new branch, so the approval here does not carry over. Closing this one; its review history stays here.

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

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants