This is an automated email from the ASF dual-hosted git repository. borinquenkid pushed a commit to branch 8.0.x-hibernate7-dev in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit b893b4348ab78b768c6c6aa6e3d172f8a3bdd1d1 Author: Walter Duque de Estrada <[email protected]> AuthorDate: Tue Mar 3 13:30:24 2026 -0600 refactor: HibernateToManyProperty.getCacheUSage --- .../cfg/domainbinding/hibernate/HibernateToManyProperty.java | 10 ++++++++++ .../domainbinding/secondpass/CollectionSecondPassBinder.java | 4 +--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateToManyProperty.java b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateToManyProperty.java index 315728b16d..ea6d8d38ac 100644 --- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateToManyProperty.java +++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateToManyProperty.java @@ -19,8 +19,11 @@ package org.grails.orm.hibernate.cfg.domainbinding.hibernate; import java.util.Map; +import java.util.Optional; + import org.grails.datastore.mapping.model.types.Basic; import org.grails.datastore.mapping.model.types.mapping.PropertyWithMapping; +import org.grails.orm.hibernate.cfg.CacheConfig; import org.grails.orm.hibernate.cfg.ColumnConfig; import org.grails.orm.hibernate.cfg.JoinTable; import org.grails.orm.hibernate.cfg.PersistentEntityNamingStrategy; @@ -58,6 +61,13 @@ public interface HibernateToManyProperty return getMappedForm().getLazy(); } + default String getCacheUSage() { + return Optional.ofNullable(getMappedForm()) + .map(PropertyConfig::getCache) + .map(CacheConfig::getUsage) + .orElse(null); + } + /** * @return Whether the collection should be bound with a foreign key */ diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/CollectionSecondPassBinder.java b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/CollectionSecondPassBinder.java index 6ee0f04118..4507e52732 100644 --- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/CollectionSecondPassBinder.java +++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/CollectionSecondPassBinder.java @@ -80,9 +80,7 @@ public class CollectionSecondPassBinder { collection.setSorted(property.isSorted()); DependantValue key = collectionKeyBinder.bind(property, associatedClass, collection); - - Optional.ofNullable(property.getMappedForm().getCache()) - .ifPresent(cacheConfig -> collection.setCacheConcurrencyStrategy(cacheConfig.getUsage())); + collection.setCacheConcurrencyStrategy(property.getCacheUSage()); bindCollectionElement(property, mappings, collection); collectionKeyColumnUpdater.forceNullableAndCheckUpdatable(key, property);
