This is an automated email from the ASF dual-hosted git repository. borinquenkid pushed a commit to branch 8.0.x-hibernate7 in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit 9e86b7396f116ae8f5140c516d3c2f476c6bbd21 Author: Walter Duque de Estrada <[email protected]> AuthorDate: Mon Feb 23 18:54:40 2026 -0600 fix compile dynamic --- .../orm/hibernate/HibernateGormStaticApi.groovy | 34 ++++++++++------------ 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/HibernateGormStaticApi.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/HibernateGormStaticApi.groovy index 08401d17f1..ad81338df5 100644 --- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/HibernateGormStaticApi.groovy +++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/HibernateGormStaticApi.groovy @@ -15,6 +15,9 @@ */ package org.grails.orm.hibernate +import org.grails.datastore.mapping.model.PersistentProperty +import org.hibernate.query.criteria.JpaRoot + import grails.orm.HibernateCriteriaBuilder import groovy.transform.CompileDynamic import groovy.transform.CompileStatic @@ -431,32 +434,25 @@ class HibernateGormStaticApi<D> extends GormStaticApi<D> { getAllInternal(ids as List) } - @CompileDynamic - private List getAllInternal(List ids) { + private List<D> getAllInternal(List ids) { if (!ids) return [] - (List)hibernateTemplate.execute { Session session -> - def identityType = persistentEntity.identity.type - def identityName = persistentEntity.identity.name - List<Object> convertedIds = ids.collect { HibernateRuntimeUtils.convertValueToType((Serializable)it, identityType, conversionService) } + hibernateTemplate.execute { Session session -> + PersistentProperty identity = persistentEntity.identity + Class<?> identityType = identity.type + String identityName = identity.name + List<Object> convertedIds = ids.collect { HibernateRuntimeUtils.convertValueToType(it, identityType, conversionService) } CriteriaBuilder cb = session.getCriteriaBuilder() - CriteriaQuery cq = cb.createQuery(persistentEntity.javaClass) - def root = cq.from(persistentEntity.javaClass) + CriteriaQuery<D> cq = cb.createQuery((Class<D>)persistentEntity.javaClass) + Root<D> root = cq.from((Class<D>)persistentEntity.javaClass) cq.select(root).where(root.get("id").in(convertedIds)) firePreQueryEvent() - List results = session.createQuery(cq).resultList + List<D> results = session.createQuery(cq).resultList firePostQueryEvent(results) - def idsMap = [:] - for (object in results) { - idsMap[object[identityName]] = object - } - results.clear() - for (id in ids) { - results << idsMap[id] - } - results - } + Map<Object, D> idsMap = results.collectEntries { [it[identityName], it] } + ids.collect { idsMap[it] } + } as List<D> }
