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 a803f75bfca6228128d3c7c9b6649742c894ec27
Author: Walter Duque de Estrada <[email protected]>
AuthorDate: Thu Oct 8 16:51:33 2026 -0500

    feat: accept a default sort on a list, a map and an association in native 
domain binding, and say why the remaining refusals stand
    
    The generated mode refused the default sort of a bidirectional hasMany when 
the collection is a list or a map, or when the sort property is an association. 
Probed with both modes: the binder keeps the sort of a list on its model but 
the list comes back in the order of its index, and it orders a map and a set by 
the property, an association by its foreign key. The generator now states no 
order for a list and the order for the others (an association by its name, 
which Hibernate orders b [...]
    
    Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
---
 .../domainbinding/jpa/GrailsDomainGenerator.groovy |  49 +++----
 ...GeneratedDomainClassesCollectionSortSpec.groovy | 163 +++++++++++++++++++++
 ...eneratedDomainClassesDdlDifferentialSpec.groovy |  10 +-
 .../GrailsDomainGeneratorDifferentialSpec.groovy   |  39 ++++-
 .../advancedGORMFeatures/nativeDomainBinding.adoc  |  25 ++--
 5 files changed, 237 insertions(+), 49 deletions(-)

diff --git 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/jpa/GrailsDomainGenerator.groovy
 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/jpa/GrailsDomainGenerator.groovy
index e9b81cd320..198d6100d7 100644
--- 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/jpa/GrailsDomainGenerator.groovy
+++ 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/jpa/GrailsDomainGenerator.groovy
@@ -461,7 +461,8 @@ class GrailsDomainGenerator {
     String generationProblem(GrailsHibernatePersistentEntity entity) {
         if (!entity.isRoot() && 
compositeIdentifier(entity.hibernateRootEntity) && entity.isJoinedSubclass()) {
             return "Entity [${entity.name}] is a joined subclass of 
[${entity.hibernateRootEntity.name}], which has a composite identifier: " +
-                    'the key of a joined subclass table copies the key of the 
root, which the binder binds with one column'
+                    'the key of a joined subclass table copies the key of the 
root, which the binder binds with one column, so the ' +
+                    'application does not start with the binder either'
         }
         try {
             hierarchyFacets(entity)
@@ -588,14 +589,14 @@ class GrailsDomainGenerator {
         }
         if (entity.childEntities.any { GrailsHibernatePersistentEntity child 
-> child.isJoinedSubclass() }) {
             return "Entity [${entity.name}] has a composite identifier and a 
joined subclass: the key of a joined subclass table copies " +
-                    'the key of the root, which the binder binds with one 
column'
+                    'the key of the root, which the binder binds with one 
column, so the application does not start with the binder either'
         }
         for (HibernatePersistentProperty part : entity.compositeIdentity) {
             if (part instanceof HibernateToOneProperty) {
                 HibernateToOneProperty toOne = (HibernateToOneProperty) part
                 if (!boundAsManyToOne(toOne)) {
                     return "Composite identifier part [${part.name}] of 
[${entity.name}] is a one-to-one the binder binds as a Hibernate " +
-                            'OneToOne, which the generator does not support 
yet'
+                            'OneToOne, which it cannot do for a part of an 
identifier: it fails with an IndexOutOfBoundsException'
                 }
                 GrailsHibernatePersistentEntity partTarget = 
toOne.hibernateAssociatedEntity?.hibernateRootEntity
                 if (partTarget != null && compositeIdentifier(partTarget)) {
@@ -611,7 +612,8 @@ class GrailsDomainGenerator {
                 }
             } else if (!(part instanceof HibernateSimpleProperty) || 
isDerived(part)) {
                 return "Composite identifier part [${part.name}] of 
[${entity.name}] is a ${part.getClass().simpleName}, which the " +
-                        'generator does not support yet'
+                        'generator does not support yet (the binder boots an 
embedded object as a part of the identifier, and Hibernate ' +
+                        'cannot state one in an identifier class)'
             } else if (!supports(part)) {
                 return "Composite identifier part [${part.name}] of 
[${entity.name}]: ${unsupportedReason(entity, part)}"
             }
@@ -797,7 +799,8 @@ class GrailsDomainGenerator {
                     property instanceof HibernateToManyEntityProperty || 
isDerived(property) ||
                     (property instanceof HibernateToOneProperty && 
boundAsOneToOne((HibernateToOneProperty) property))) {
                 return "The natural id of [${entity.name}] names [${name}], 
which is ${property.getClass().simpleName}: " +
-                        'only a simple property, an enum, a foreign key or an 
embedded type can be part of a natural id the generator states'
+                        'only a simple property, an enum, a foreign key or an 
embedded type can be part of a natural id, and the binder ' +
+                        'cannot bind a collection (ClassCastException) or a 
formula (constraint involves a formula) either'
             }
         }
         return null
@@ -971,7 +974,7 @@ class GrailsDomainGenerator {
         if (strategy != hierarchyStrategy) {
             throw new UnsupportedOperationException(
                     "Entity [${entity.name}] uses ${strategy} but the root of 
its hierarchy uses ${hierarchyStrategy}: " +
-                            'a hierarchy that mixes inheritance strategies is 
not supported')
+                            'a hierarchy that mixes inheritance strategies is 
not supported, and the binder fails on it with a NullPointerException')
         }
         boolean singleTable = strategy == InheritanceType.SINGLE_TABLE
         String discriminatorValue = null
@@ -1312,7 +1315,7 @@ class GrailsDomainGenerator {
         }
     }
 
-    private static final String severalKeyColumns = 'the mapping states 
several columns for the key of a collection of an entity with a ' +
+    private static final String SEVERAL_KEY_COLUMNS = 'the mapping states 
several columns for the key of a collection of an entity with a ' +
             'simple identifier: the binder gives the key as many columns as 
the mapping states and Hibernate refuses the foreign key ' +
             "('Foreign key must have the same number of columns as the 
referenced primary key'), so the application does not start"
 
@@ -1345,7 +1348,7 @@ class GrailsDomainGenerator {
                 return compositeProblem
             }
         } else if (mapped.columns != null && mapped.columns.size() > 1) {
-            return severalKeyColumns
+            return SEVERAL_KEY_COLUMNS
         }
         boolean isEnum = property instanceof HibernateEnumProperty
         if (isEnum && kind == CollectionKind.MAP) {
@@ -1783,7 +1786,7 @@ class GrailsDomainGenerator {
         }
         if (!compositeIdentifier(property.hibernateOwner) && 
!property.shouldBindWithForeignKey() &&
                 mapped.columns != null && mapped.columns.size() > 1) {
-            return severalKeyColumns
+            return SEVERAL_KEY_COLUMNS
         }
         if (property.isUserButNotCollectionType()) {
             return 'a class is mapped as the type of the collection property, 
which the binder binds as one column of the owner\'s table ' +
@@ -1795,9 +1798,8 @@ class GrailsDomainGenerator {
                 return "the other side [${other?.name}] is not a many-to-many 
collection"
             }
             if (!ownsManyToMany(property) && 
!ownsManyToMany((HibernateManyToManyProperty) other)) {
-                return 'neither side of the many-to-many owns it (no 
belongsTo): the binder binds both collections inverse, so ' +
-                        'no row is ever written, and annotations cannot say it 
(Hibernate\'s annotation binder fails with a ' +
-                        'NullPointerException when both sides are mappedBy)'
+                return 'neither side of the many-to-many owns it (no 
belongsTo): no row would ever be written, and the binder refuses it ' +
+                        'too at startup'
             }
         } else if (property.bidirectional) {
             if (!(property.hibernateInverseSide instanceof 
HibernateManyToOneProperty)) {
@@ -1808,15 +1810,6 @@ class GrailsDomainGenerator {
         if (indexTypeProblem != null) {
             return indexTypeProblem
         }
-        if (property.hasSort()) {
-            if (kind.indexed) {
-                return 'a list or a map with a default sort: it is ordered by 
its index or key column'
-            }
-            HibernatePersistentProperty sortBy = 
target.getHibernatePropertyByName(property.sort)
-            if (!(sortBy instanceof HibernateSimpleProperty) && !(sortBy 
instanceof HibernateEnumProperty) || isDerived(sortBy)) {
-                return "the sort property [${property.sort}] of 
[${target.name}] is not a plain column"
-            }
-        }
         return null
     }
 
@@ -1953,8 +1946,10 @@ class GrailsDomainGenerator {
                 Math.max(property.batchSize, 0),
                 property.cacheUsage,
                 cascadeFacets(property),
-                property.hasSort() ? property.sort : null,
-                property.hasSort() ? (property.order != null ? property.order 
: 'asc') : null,
+                // a list is ordered by its index column, so the binder's 
order-by of a list changes nothing (probed: the elements come back in
+                // the order they were stored)
+                property.hasSort() && kind != CollectionKind.LIST ? 
property.sort : null,
+                property.hasSort() && kind != CollectionKind.LIST ? 
(property.order != null ? property.order : 'asc') : null,
                 condition,
                 keys != null ? keys : [key],
                 keys != null ? collectionKeyReferencedColumns(property) : [],
@@ -1972,7 +1967,8 @@ class GrailsDomainGenerator {
         boolean inverseOneToOne = boundAsOneToOne(property)
         if (inverseOneToOne && ((HibernateOneToOneProperty) 
property).needsSimpleValueBinding()) {
             return 'the binder binds this one-to-one as a Hibernate OneToOne 
with a column of its own (constrained), ' +
-                    'which the generator does not support yet'
+                    'which it cannot do: both sides are hasOne and the 
application does not start with the binder either ' +
+                    "('PostInitCallback queue could not be processed')"
         }
         GrailsHibernatePersistentEntity target = 
property.hibernateAssociatedEntity
         if (target == null) {
@@ -1989,10 +1985,11 @@ class GrailsDomainGenerator {
                 return problem
             }
         } else if (mapped.columns != null && mapped.columns.size() > 1) {
-            return 'the mapping states several columns, which the binder binds 
as a composite foreign key'
+            return 'the mapping states several columns, which the binder binds 
as a composite foreign key and Hibernate refuses because ' +
+                    "the key it points at has one column ('Foreign key must 
have the same number of columns as the referenced primary key')"
         }
         if (mapped.derived) {
-            return 'the association is mapped with a formula'
+            return 'the association is mapped with a formula, which the binder 
cannot bind either (AssertionFailure: value involves formulas)'
         }
         return null
     }
diff --git 
a/grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/generated/GeneratedDomainClassesCollectionSortSpec.groovy
 
b/grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/generated/GeneratedDomainClassesCollectionSortSpec.groovy
new file mode 100644
index 0000000000..86b1c5f7c7
--- /dev/null
+++ 
b/grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/generated/GeneratedDomainClassesCollectionSortSpec.groovy
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package grails.gorm.tests.generated
+
+import java.util.concurrent.atomic.AtomicInteger
+
+import grails.gorm.annotation.Entity
+import spock.lang.AutoCleanup
+import spock.lang.Specification
+import spock.lang.Unroll
+
+import org.grails.orm.hibernate.HibernateDatastore
+
+/**
+ * The default {@code sort} of a bidirectional {@code hasMany}. The domain 
binder orders a set and a map by the property, also when it
+ * is an association (it orders by the foreign key), and a list stays in the 
order of its index column, so the sort changes nothing for
+ * it. The generated mode accepts all three the same way instead of refusing 
the list, the map and the sort by an association.
+ */
+class GeneratedDomainClassesCollectionSortSpec extends Specification {
+
+    static final AtomicInteger BOOTS = new AtomicInteger()
+
+    @AutoCleanup
+    HibernateDatastore datastore
+
+    private HibernateDatastore boot(List<Class> group, boolean generated) {
+        datastore?.close()
+        datastore = new HibernateDatastore([
+                'dataSource.url'                  : 
"jdbc:h2:mem:gcs${BOOTS.incrementAndGet()};LOCK_TIMEOUT=10000".toString(),
+                'dataSource.dbCreate'             : 'create-drop',
+                'hibernate.generatedDomainClasses': generated,
+        ], group as Class[])
+        return datastore
+    }
+
+    @Unroll
+    void "#label: the elements come back in the same order in both modes"() {
+        when:
+        Map<Boolean, Object> results = [false, true].collectEntries { boolean 
generated ->
+            boot(group, generated)
+            [(generated): this."${cycle}"()]
+        }
+
+        then:
+        results[true] == results[false]
+        results[true] == expected
+
+        where:
+        label                              | group                          | 
cycle          | expected
+        'a list with a sort'               | [GcsListOwner, GcsListKid]     | 
'listCycle'    | ['b', 'a', 'c']
+        'a map with a sort'                | [GcsMapOwner, GcsMapKid]       | 
'mapCycle'     | [k2: 'a', k1: 'b']
+        'a set sorted by an association'   | [GcsRefOwner, GcsRefKid, GcsRef] 
| 'refCycle'   | ['y', 'x']
+    }
+
+    private List listCycle() {
+        GcsListOwner.withTransaction {
+            GcsListOwner owner = new GcsListOwner()
+            ['b', 'a', 'c'].each { owner.addToKids(new GcsListKid(name: it)) }
+            owner.save(failOnError: true, flush: true)
+        }
+        return GcsListOwner.withNewSession { 
GcsListOwner.list().first().kids*.name }
+    }
+
+    private Map mapCycle() {
+        GcsMapOwner.withTransaction {
+            GcsMapOwner owner = new GcsMapOwner()
+            owner.kids = [k1: new GcsMapKid(name: 'b'), k2: new 
GcsMapKid(name: 'a')]
+            owner.save(failOnError: true, flush: true)
+        }
+        return GcsMapOwner.withNewSession { 
GcsMapOwner.list().first().kids.collectEntries { String key, GcsMapKid kid -> 
[(key): kid.name] } }
+    }
+
+    private List refCycle() {
+        GcsRefOwner.withTransaction {
+            GcsRef first = new GcsRef(label: 'r1').save(failOnError: true)
+            GcsRef second = new GcsRef(label: 'r2').save(failOnError: true)
+            GcsRefOwner owner = new GcsRefOwner()
+            owner.addToKids(new GcsRefKid(name: 'x', ref: second))
+            owner.addToKids(new GcsRefKid(name: 'y', ref: first))
+            owner.save(failOnError: true, flush: true)
+        }
+        return GcsRefOwner.withNewSession { 
GcsRefOwner.list().first().kids*.name }
+    }
+}
+
+@Entity
+class GcsListOwner {
+    List<GcsListKid> kids
+
+    static hasMany = [kids: GcsListKid]
+
+    static mapping = {
+        kids sort: 'name'
+    }
+}
+
+@Entity
+class GcsListKid {
+    String name
+    GcsListOwner owner
+
+    static belongsTo = [owner: GcsListOwner]
+}
+
+@Entity
+class GcsMapOwner {
+    Map<String, GcsMapKid> kids
+
+    static hasMany = [kids: GcsMapKid]
+
+    static mapping = {
+        kids sort: 'name'
+    }
+}
+
+@Entity
+class GcsMapKid {
+    String name
+    GcsMapOwner owner
+
+    static belongsTo = [owner: GcsMapOwner]
+}
+
+@Entity
+class GcsRef {
+    String label
+}
+
+@Entity
+class GcsRefOwner {
+    Set<GcsRefKid> kids
+
+    static hasMany = [kids: GcsRefKid]
+
+    static mapping = {
+        kids sort: 'ref'
+    }
+}
+
+@Entity
+class GcsRefKid {
+    String name
+    GcsRef ref
+    GcsRefOwner owner
+
+    static belongsTo = [owner: GcsRefOwner]
+}
diff --git 
a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/jpa/GeneratedDomainClassesDdlDifferentialSpec.groovy
 
b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/jpa/GeneratedDomainClassesDdlDifferentialSpec.groovy
index b29aa1a7ec..230e34a754 100644
--- 
a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/jpa/GeneratedDomainClassesDdlDifferentialSpec.groovy
+++ 
b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/jpa/GeneratedDomainClassesDdlDifferentialSpec.groovy
@@ -76,14 +76,6 @@ class GeneratedDomainClassesDdlDifferentialSpec extends 
Specification {
             [id: 'UNIQUE_GROUP_ON_ENUM', reason: 'A binder defect (pinned in 
GrailsDomainBinderOptionDefectSpec): a unique group that includes an enum 
property is dropped by the binder. The generated mode creates the constraint 
the mapping states, so a database created by the binder lacks it and `update` 
would add it. 2 groups in the scanned domains.']
     ]
 
-    /**
-     * The reasons the generated mode may refuse a group the domain binder 
boots: each is a mapping the generator rejects by name
-     * because no annotation can state it faithfully. A refusal for any other 
reason fails the spec.
-     */
-    private static final List<String> REFUSALS = [
-            'neither side of the many-to-many owns it',
-    ]
-
     private static final AtomicInteger BOOTS = new AtomicInteger()
 
     void "the generated-class mode creates the same schema as the domain 
binder"() {
@@ -130,7 +122,7 @@ class GeneratedDomainClassesDdlDifferentialSpec extends 
Specification {
         compared > 400
         unknown.isEmpty()
         unexplained.isEmpty()
-        generatedRefused.findAll { String name, String reason -> !REFUSALS.any 
{ String known -> reason.contains(known) } }.isEmpty()
+        generatedRefused.isEmpty()
     }
 
     private static Map knownEntry(Map difference) {
diff --git 
a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/jpa/GrailsDomainGeneratorDifferentialSpec.groovy
 
b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/jpa/GrailsDomainGeneratorDifferentialSpec.groovy
index 0fabe92f70..0ff4349d02 100644
--- 
a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/jpa/GrailsDomainGeneratorDifferentialSpec.groovy
+++ 
b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/jpa/GrailsDomainGeneratorDifferentialSpec.groovy
@@ -1728,6 +1728,20 @@ class GrailsDomainGeneratorDifferentialSpec extends 
HibernateGormDatastoreSpec {
         return sortBy.selectables.collect { "${it.text} 
${facets.orderDirection()}".toString() }.join(', ')
     }
 
+    /**
+     * The order-by of the generator's facets against the binder's collection. 
The binder keeps the default sort of a list on its
+     * model although a list is ordered by its index column (probed: the 
elements come back in the order they were stored), so the
+     * generator states none.
+     */
+    private static List orderByPair(
+            HibernateToManyEntityProperty property, ToManyFacets facets, 
HibernateCollection collection, Map<String, Integer> known) {
+        if (facets.kind() == CollectionKind.LIST && collection.orderBy != 
null) {
+            known['the binder keeps the default sort of a list on its model, 
which is ordered by its index column; the generator states none']++
+            return [null, null]
+        }
+        return [normalizedOrderBy(orderByOf(property, facets)), 
normalizedOrderBy(collection.orderBy)]
+    }
+
     private static String normalizedOrderBy(String orderBy) {
         return orderBy?.toLowerCase()?.replaceAll(/\s+/, ' ')?.trim()
     }
@@ -1754,7 +1768,7 @@ class GrailsDomainGeneratorDifferentialSpec extends 
HibernateGormDatastoreSpec {
                 orphanDelete: [facets.cascade().orphanRemoval(), 
collection.hasOrphanDelete()],
                 cascade    : [cascadeActions(facets.cascade()), 
cascadeActions(boundProperty.cascade)],
                 oneToMany  : [!facets.manyToMany(), collection.oneToMany],
-                orderBy    : [normalizedOrderBy(orderByOf(property, facets)), 
normalizedOrderBy(collection.orderBy)],
+                orderBy    : orderByPair(property, facets, collection, known),
                 element    : [facets.target(), collection.element instanceof 
OneToMany ? ((OneToMany) collection.element).referencedEntityName :
                         ((ToOne) collection.element).referencedEntityName],
         ]
@@ -1844,7 +1858,7 @@ class GrailsDomainGeneratorDifferentialSpec extends 
HibernateGormDatastoreSpec {
                 orphanDelete: [bound.hasOrphanDelete(), 
annotated.hasOrphanDelete()],
                 oneToMany   : [bound.oneToMany, annotated.oneToMany],
                 cascade     : [cascadeActions(boundProperty.cascade), 
cascadeActions(annotatedProperty.cascade)],
-                orderBy     : [normalizedOrderBy(bound.orderBy), 
normalizedOrderBy(annotated.orderBy ?: annotated.manyToManyOrdering)],
+                orderBy     : annotatedOrderByPair(facets, bound, annotated, 
byName, known),
                 element     : 
[GrailsDomainGenerator.generatedClassName(byName[facets.target()]),
                                annotated.element instanceof OneToMany ? 
((OneToMany) annotated.element).referencedEntityName :
                                        ((ToOne) 
annotated.element).referencedEntityName],
@@ -1902,6 +1916,27 @@ class GrailsDomainGeneratorDifferentialSpec extends 
HibernateGormDatastoreSpec {
         return found
     }
 
+    /**
+     * The order-by of the binder's collection against the one the annotation 
binder built. A list states none (see {@link #orderByPair}),
+     * and a sort by an association is the foreign key column for the binder 
and the name of the association for the annotation.
+     */
+    private static List annotatedOrderByPair(
+            ToManyFacets facets, HibernateCollection bound, 
HibernateCollection annotated,
+            Map<String, GrailsHibernatePersistentEntity> byName, Map<String, 
Integer> known) {
+        String boundOrder = normalizedOrderBy(bound.orderBy)
+        String annotatedOrder = normalizedOrderBy(annotated.orderBy ?: 
annotated.manyToManyOrdering)
+        if (facets.kind() == CollectionKind.LIST && boundOrder != null && 
annotatedOrder == null) {
+            known['the binder keeps the default sort of a list on its model, 
which is ordered by its index column; the generator states none']++
+            return [null, null]
+        }
+        if (boundOrder != annotatedOrder && facets.orderProperty() != null &&
+                
byName[facets.target()].getHibernatePropertyByName(facets.orderProperty()) 
instanceof HibernateToOneProperty) {
+            known['a sort by an association is the foreign key column for the 
binder and the name of the association for the annotation']++
+            return [annotatedOrder, annotatedOrder]
+        }
+        return [boundOrder, annotatedOrder]
+    }
+
     /**
      * A collection of the binder's entity against the one Hibernate's 
annotation binder built: the same kind, table, key,
      * element and index columns, and the same fetching and caching.
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 e720267976..6207ac1f94 100644
--- 
a/grails-data-hibernate7/docs/src/docs/asciidoc/advancedGORMFeatures/nativeDomainBinding.adoc
+++ 
b/grails-data-hibernate7/docs/src/docs/asciidoc/advancedGORMFeatures/nativeDomainBinding.adoc
@@ -74,14 +74,13 @@ For the domain classes in GORM's own test suites, both 
bindings produce the same
 * The `defaultValue`, `comment`, `read` and `write` of the column mapping of 
an association or of a `hasMany` are put on the foreign key column (on the key 
column of a collection, and on the element column of a many-to-many for the 
options of the other side). The `length`, `precision` and `scale` change 
nothing: a foreign key column has the type of the column it references, and a 
`hasMany` of basic values ignores them too. This is the same in both bindings.
 * A many-to-many or a map of domain classes may involve an entity with a 
composite identifier on either side or on both: the join table has a key column 
for each identifier property of the owner and an element column for each one of 
the target, named as with classic binding. A foreign key to a composite 
identifier that the mapping gives fewer columns than the identifier has 
properties keeps the columns the mapping names and names the missing ones as 
classic binding does.
 * A `joinTable` that names several `key` columns uses the first one in both 
bindings (the other names are ignored). A `type` that names a Java class that 
is no `UserType` or converter, for example `type: 'java.util.Date'`, gives the 
column of the type Hibernate registers for that class, and a property of a 
class GORM does not know (a `Serializable` class, with no `type`) is stored as 
bytes. An embedded property with a `type` that is a `UserType` is one column of 
that type, not an embedde [...]
+* The default `sort` of a bidirectional `hasMany` orders a set and a map by 
the property, also when it is an association (by its foreign key), and does 
nothing for a list, which stays in the order of its index. This is the same in 
both bindings.
 * Identifier generators, inheritance strategies (single table, joined and 
table-per-concrete-class), discriminators, natural ids, optimistic locking, 
lazy and eager fetching, cascades, sorting, batch size and `cache` usage are 
mapped as with classic binding.
 
 [[nativeDomainBinding-refused]]
 === Mappings Native Binding Refuses
 
-Where an annotation cannot express a mapping option faithfully, native binding 
refuses the mapping instead of dropping the option. The application fails at 
startup. The exception has an `UnsupportedOperationException` as its root 
cause, and the message names the domain class and the property.
-
-Nothing is ignored silently. A mapping that boots is bound the way it is 
written.
+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.
 
 [cols="2,3,3", options="header"]
 |===
@@ -91,27 +90,29 @@ Nothing is ignored silently. A mapping that boots is bound 
the way it is written
 
 | A natural id that names a collection or a formula.
 | `The natural id of [...] names [...], which is ... only a simple property, 
an enum, a foreign key or an embedded type can be part of a natural id ...`
-| Name only simple properties, enums, many-to-one associations and embedded 
objects in `natural`. Classic binding does not boot either: it fails with a 
`ClassCastException` for a collection and with `constraint involves a formula` 
for a formula.
+| Name only simple properties, enums, many-to-one associations and embedded 
objects in `natural`. Classic binding fails with a `ClassCastException` for a 
collection and with `constraint involves a formula` for a formula.
 
 | A `type` on a `hasMany` of basic values that is a registered Hibernate type 
name, for example `type: 'text'`, or a custom collection type.
 | `Collection property [...]: the type [...] mapped on the collection property 
names neither a class nor serializable ...` or `... a custom collection type (a 
UserCollectionType) is mapped on a collection of basic values ...`
-| Remove the `type`, or use `'serializable'` or a `UserType` class to store 
the collection in one column. Classic binding does not boot with a registered 
type name (it fails with `Could not load requested class`), and neither with a 
custom collection type on a collection of basic values.
+| Remove the `type`, or use `'serializable'` or a `UserType` class to store 
the collection in one column. Classic binding fails with `Could not load 
requested class`, and with a custom collection type on a collection of basic 
values.
 
-| A composite identifier combined with something that classic binding cannot 
boot either: a `hasMany` of domain classes with a join table to an entity with 
a composite identifier (a many-to-many and a map of a many-to-many are fine), a 
join table whose key columns are mapped on an entity with a composite 
identifier, a composite identifier part that is the inverse side of a 
one-to-one, a part that refers to an entity with a simple identifier or to a 
composite identifier more than one leve [...]
+| A composite identifier combined with something classic binding cannot boot: 
a `hasMany` of domain classes that is not a many-to-many and uses a join table 
to an entity with a composite identifier, a join table whose key columns are 
mapped on an entity with a composite identifier, a composite identifier part 
that is the inverse side of a one-to-one, a part that refers to an entity with 
a simple identifier or to a composite identifier more than one level deep, a 
joined subclass of such a [...]
 | `... composite identifier ...`, naming the entity and the part.
 | Give the entity a single-column identifier, or map the relationship with a 
domain class of its own. Classic binding fails with `Foreign key ... must have 
same number of columns as the referenced primary key` or an 
`IndexOutOfBoundsException`.
 
+| Several columns mapped on a property that has one: on a simple property, on 
an association to an entity with a simple identifier, or on the key of a 
`hasMany` of an entity with a simple identifier. An association mapped with a 
`formula`. A one-to-one declared `hasOne` on both sides.
+| `... the mapping states several columns ...`, `... the association is mapped 
with a formula ...` or `... the binder binds this one-to-one as a Hibernate 
OneToOne with a column of its own ...`
+| Map the property or the association with a single `column`. Classic binding 
fails with `Foreign key ... must have same number of columns as the referenced 
primary key`, `maps to 2 columns but 1 columns are required`, `value involves 
formulas` or `PostInitCallback queue could not be processed`.
+
+| A collection that classic binding cannot create: a `SortedSet` of basic 
values, a `UserType` class as the `type` of a `hasMany` of domain classes, a 
`Map` of enums, a collection declared with a type that is not `Set`, 
`SortedSet`, `List`, `Collection` or `Map` (for example `HashSet`), a `hasMany` 
of a class that is not a domain class, an unknown `indexColumn` type, a default 
`sort` on a unidirectional `hasMany`, a `Map` or `Set` on a many-to-many that 
neither side owns (no `belongsTo`) [...]
+| `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.
+
 | 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.
-
-| An association mapped with a `formula`, or with several columns where the 
target does not have a composite identifier.
-| `... the association is mapped with a formula` or `... the mapping states 
several columns ...`
-| Map the association with a single `column`.
 |===
 
-A few mappings fail to boot with classic binding too, so they are not a 
difference between the two: a `SortedSet` of basic values, a `UserType` class 
as the `type` of a `hasMany` of domain classes, a `Map` of enums, a hierarchy 
that mixes inheritance strategies and a joined subclass of a root with a 
composite identifier.
-
 [[nativeDomainBinding-behavior]]
 === Differences in Behavior
 

Reply via email to