This is an automated email from the ASF dual-hosted git repository. borinquenkid pushed a commit to branch 9.0.x-h7-improvement-phase3 in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit 71e31c58ca10c6d3e5259f777afd54ebd27331dd Author: Walter Duque de Estrada <[email protected]> AuthorDate: Thu Oct 8 16:56:14 2026 -0500 docs: list only the mappings classic binding cannot use as refused by native binding The manual's table of refused mappings now lists the mappings that the domain binder cannot boot or cannot use (with what it does), and the one exception, an embedded object as a part of a composite identifier. The behavior and schema tables describe the owners of a shared embedded collection, and the list of things that stay the same names what the generated mode now accepts: write flags on columnless properties, discriminator precision and type, a mapped type on the tenant id, colum [...] Co-Authored-By: Claude Sonnet 5.5 <[email protected]> --- .../asciidoc/advancedGORMFeatures/nativeDomainBinding.adoc | 12 ++++++++---- grails-doc/src/en/guide/upgrading/upgrading90x.adoc | 5 +++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/grails-data-hibernate7/docs/src/docs/asciidoc/advancedGORMFeatures/nativeDomainBinding.adoc b/grails-data-hibernate7/docs/src/docs/asciidoc/advancedGORMFeatures/nativeDomainBinding.adoc index 6207ac1f94..2ff765edcd 100644 --- a/grails-data-hibernate7/docs/src/docs/asciidoc/advancedGORMFeatures/nativeDomainBinding.adoc +++ b/grails-data-hibernate7/docs/src/docs/asciidoc/advancedGORMFeatures/nativeDomainBinding.adoc @@ -80,7 +80,7 @@ For the domain classes in GORM's own test suites, both bindings produce the same [[nativeDomainBinding-refused]] === Mappings Native Binding Refuses -Native binding does not refuse a mapping that classic binding accepts and can use. It refuses the mappings below, which classic binding cannot use either: classic binding fails to start with them, or it boots them and fails on the first row. The application fails at startup. The exception has an `UnsupportedOperationException` as its root cause, and the message names the domain class and the property, and says what classic binding does with the mapping. +Native binding does not refuse a mapping that classic binding accepts and can use, with the one exception at the end of the table. It refuses the mappings below, which classic binding cannot use either: classic binding fails to start with them, or it boots them and fails on the first row. The application fails at startup. The exception has an `UnsupportedOperationException` as its root cause, and the message names the domain class and the property, and says what classic binding does with [...] [cols="2,3,3", options="header"] |=== @@ -108,6 +108,10 @@ Native binding does not refuse a mapping that classic binding accepts and can us | `Collection property [...]: ...`, `Association property [...]: ...` or `Entity [...] uses ... but the root of its hierarchy uses ...` | Change the mapping as the message says. Classic binding fails to start with each of them. +| An embedded object as a part of a composite identifier (`id composite: ['code', 'address']` where `address` is listed in `static embedded`). Classic binding boots this mapping; native binding does not support it yet. +| `Composite identifier part [...] of [...] is a HibernateEmbeddedProperty, which the generator does not support yet ...` +| Name the properties of the embedded class in the identifier, or give the entity a single-column identifier. + | A registered Hibernate type name as the `type` of an enum property (`type: 'integer'`), or a registered type that converts its value (`yes_no`) as the `type` of the `indexColumn` of a list or a map. | `Type [...] of property [...] is a registered type on an enum ...` or `... the index column type [...] is a registered type that converts its value ...` | Remove the `type` (an enum is stored as a string unless `enumType` says otherwise). Classic binding boots these mappings but cannot use them: saving a row fails with a `ClassCastException` for the enum, with a check constraint violation for the list, and the table of the map is not created. @@ -148,7 +152,7 @@ Some bugs of classic binding are not copied by native binding. Native binding do [[nativeDomainBinding-schema]] === Differences in the Schema -The schema of 734 groups of related domain classes was created with both bindings on H2 and compared: tables, columns with type, nullability, default, length, precision and scale, primary keys with their column order, foreign keys, unique keys, indexes, check constraints and sequences. Native binding booted every group that classic binding boots, and these are the differences. Other databases are not covered by this comparison, so verify against your own database as described below. +The schema of 765 groups of related domain classes was created with both bindings on H2 and compared: tables, columns with type, nullability, default, length, precision and scale, primary keys with their column order, foreign keys, unique keys, indexes, check constraints and sequences. Native binding booted every group that classic binding boots, and these are the differences. Other databases are not covered by this comparison, so verify against your own database as described below. [cols="2,3,3", options="header"] |=== @@ -211,7 +215,7 @@ The comparison finds no difference in the unique keys, indexes and identifier co Do not switch a production database over blindly. Whether `dbCreate: update` or a Liquibase changelog would change anything depends on the differences above. -. Start the application with `hibernate.generatedDomainClasses: true` against a copy of your schema. Fix every refused mapping from the table above. +. Start the application with `hibernate.generatedDomainClasses: true` against a copy of your schema. Fix every refused mapping from the table above; classic binding cannot use these either. . Run <<ref-diff-scripts-dbm-gorm-diff,dbm-gorm-diff>> against the copy. An empty diff means the switch does not change the schema. Otherwise, compare each reported change with the table above, and apply the changes you want through a migration. . Run your test suite once with the setting on. . Set the property in the environment where you want it first, for example in `development` only. @@ -228,4 +232,4 @@ Envers audits the same entities and writes the same revisions with both bindings === Reporting an Unsupported Mapping -If a mapping is refused that you think should work, or if the schema differs in a way that this page does not list, open an issue at https://github.com/apache/grails-core/issues with the domain classes, the `static mapping` blocks and the exception message or the DDL of each binding. The refusals above are not permanent; each one is a mapping that native binding does not yet express, and the list is expected to shrink. +If a mapping is refused that you think should work, or if the schema differs in a way that this page does not list, open an issue at https://github.com/apache/grails-core/issues with the domain classes, the `static mapping` blocks and the exception message or the DDL of each binding. Native binding is meant to accept every mapping that classic binding can use, so a mapping that classic binding accepts and uses and that native binding refuses is a bug of native binding. diff --git a/grails-doc/src/en/guide/upgrading/upgrading90x.adoc b/grails-doc/src/en/guide/upgrading/upgrading90x.adoc index 6bf7c2ca78..5443ca5034 100644 --- a/grails-doc/src/en/guide/upgrading/upgrading90x.adoc +++ b/grails-doc/src/en/guide/upgrading/upgrading90x.adoc @@ -98,9 +98,10 @@ hibernate: Your domain classes, your queries and the GORM API do not change. The mapping can, though: -* A few mapping options cannot be expressed with annotations. - Native binding refuses such a mapping with an `UnsupportedOperationException` at startup instead of ignoring the option. +* Native binding refuses a mapping only when classic binding cannot use it either: classic binding fails to start with it, or boots it and fails on the first row. + The refusal is an `UnsupportedOperationException` at startup that says what classic binding does. The manual chapter lists them. + The one exception today is an embedded object as a part of a composite identifier, which classic binding boots and native binding does not support yet. * The generated schema differs from the one of classic binding in a few documented cases, for example a `check (idx >= 0)` constraint on the index column of every list, and the column types of foreign keys to nested composite identifiers. * A few defects of classic binding are not copied, such as a `unique` group that includes an enum property being dropped. * A `hasMany` inside a class listed in `static embedded` that more than one embedded property embeds gets a collection table of its own for every owner.
