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 f08ee3a364848712d8ca1f7c90cdae448084b3c8 Author: Walter Duque de Estrada <[email protected]> AuthorDate: Wed Mar 4 13:15:46 2026 -0600 clean up HibernateQuery --- .../groovy/org/grails/orm/hibernate/query/HibernateQuery.java | 9 +++++++-- .../gorm/specs/hibernatequery/HibernateQuerySpec.groovy | 11 +++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/HibernateQuery.java b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/HibernateQuery.java index 111390a1d8..e0aaf8c1d2 100644 --- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/HibernateQuery.java +++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/HibernateQuery.java @@ -62,7 +62,7 @@ public class HibernateQuery extends Query { return detachedCriteria; } - private Map<String, CriteriaAndAlias> createdAssociationPaths = new HashMap<>(); + private final Map<String, CriteriaAndAlias> createdAssociationPaths = new HashMap<>(); protected LinkedList<PersistentEntity> entityStack = new LinkedList<>(); protected LinkedList<Association> associationStack = new LinkedList<>(); protected DetachedCriteria<?> detachedCriteria; @@ -219,6 +219,7 @@ public class HibernateQuery extends Query { public Query not(Criterion a) { not( new Closure(HibernateQuery.this) { + @SuppressWarnings("unused") // called reflectively by the Groovy runtime as the closure body public void doCall() { ((DetachedCriteria) getDelegate()).add(a); } @@ -623,7 +624,11 @@ public class HibernateQuery extends Query { } @Override - @SuppressWarnings("PMD.CloneThrowsCloneNotSupportedException") + @SuppressWarnings({ + "PMD.CloneThrowsCloneNotSupportedException", + "CloneDoesntCallSuperClone" // intentional: constructs a fresh instance via the session template + // to avoid shallow-copying the live Session and DetachedCriteria state + }) public HibernateQuery clone() { final HibernateSession hibernateSession = (HibernateSession) getSession(); final GrailsHibernateTemplate hibernateTemplate = diff --git a/grails-data-hibernate7/core/src/test/groovy/grails/gorm/specs/hibernatequery/HibernateQuerySpec.groovy b/grails-data-hibernate7/core/src/test/groovy/grails/gorm/specs/hibernatequery/HibernateQuerySpec.groovy index 09de989d4d..49e3694019 100644 --- a/grails-data-hibernate7/core/src/test/groovy/grails/gorm/specs/hibernatequery/HibernateQuerySpec.groovy +++ b/grails-data-hibernate7/core/src/test/groovy/grails/gorm/specs/hibernatequery/HibernateQuerySpec.groovy @@ -1043,6 +1043,17 @@ class HibernateQuerySpec extends HibernateGormDatastoreSpec { scroll != null } + def scrollWithSession() { + given: + hibernateQuery.eq("firstName", "Bob") + when: + def session = sessionFactory.openSession() + def scroll = hibernateQuery.scroll(session) + session.close() + then: + scroll != null + } + def equalsAllQueryable() { given: new Pet(name: "Lucky", age: 50, owner: oldBob).save(flush:true)
