From 0df30a626372fac79aa0ec95543119c4ae0332b9 Mon Sep 17 00:00:00 2001 From: Lee Wexler Date: Tue, 31 Oct 2023 17:24:05 -0400 Subject: [PATCH] Workaround for grails/gorm-hibernate5#750 (#315) --- CHANGELOG.md | 8 ++++++++ .../groovy/io/xh/hoist/HoistCoreGrailsPlugin.groovy | 10 +++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4202e85b..d78cf3f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 18.0-SNAPSHOT - unreleased + +### 🐞 Bugfixes + +* Workaround for GORM issue with unconstrained findAll() and list() breaking eager fetching. + See https://github.com/grails/gorm-hibernate5/issues/750 + + ## 17.3.0 - 2023-09-18 ### ⚙️ Technical diff --git a/src/main/groovy/io/xh/hoist/HoistCoreGrailsPlugin.groovy b/src/main/groovy/io/xh/hoist/HoistCoreGrailsPlugin.groovy index 3d21f3f9..2b7f4b29 100644 --- a/src/main/groovy/io/xh/hoist/HoistCoreGrailsPlugin.groovy +++ b/src/main/groovy/io/xh/hoist/HoistCoreGrailsPlugin.groovy @@ -48,7 +48,15 @@ class HoistCoreGrailsPlugin extends Plugin { } } - void doWithDynamicMethods() {} + void doWithDynamicMethods() { + // Workaround for issue with unconstrained findAll() and list(). + // See https://github.com/grails/gorm-hibernate5/issues/750 + grailsApplication.domainClasses.each { + def meta = it.metaClass.static + meta.list = meta.findAll = { delegate.findAll({}) } + meta.list = meta.findAll = { Map params -> delegate.findAll(params, {}) } + } + } void doWithApplicationContext() {}