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 9870809c018f5e0667096b804c1bd6cd658703e6 Author: Walter B Duque de Estrada <[email protected]> AuthorDate: Tue Jan 27 13:56:10 2026 -0600 progress --- grails-data-hibernate7/core/01.txt | 1 - .../grails/gorm/specs/perf/JoinPerfSpec.groovy | 26 ++++++++++++++++------ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/grails-data-hibernate7/core/01.txt b/grails-data-hibernate7/core/01.txt index 386c407220..60b766bd64 100644 --- a/grails-data-hibernate7/core/01.txt +++ b/grails-data-hibernate7/core/01.txt @@ -1,4 +1,3 @@ AttachMethodSpec. Test attach method BuiltinUniqueConstraintWorksWithTargetProxiesConstraintsSpec. test unique constraint for the associated child object BuiltinUniqueConstraintWorksWithTargetProxiesConstraintsSpec. test unique constraint on root instance -JoinPerfSpec. test read performance with join query diff --git a/grails-data-hibernate7/core/src/test/groovy/grails/gorm/specs/perf/JoinPerfSpec.groovy b/grails-data-hibernate7/core/src/test/groovy/grails/gorm/specs/perf/JoinPerfSpec.groovy index 8a418d153c..6b3bd0738f 100644 --- a/grails-data-hibernate7/core/src/test/groovy/grails/gorm/specs/perf/JoinPerfSpec.groovy +++ b/grails-data-hibernate7/core/src/test/groovy/grails/gorm/specs/perf/JoinPerfSpec.groovy @@ -50,15 +50,27 @@ class JoinPerfSpec extends Specification { datastore.sessionFactory.currentSession.clear() } - for(i in 0..7000) { - Author a = Author.get(Math.abs(new Random().nextInt() % 500) + 1) - Book b = Book.get(Math.abs(new Random().nextInt() % 1500) + 1) - if(a && b) { - new BookAuthor(book: b, author: a).save() + Set<List<Long>> seen = [] + int count = 0 + Random random = new Random() + while(count < 7000) { + long authorId = Math.abs(random.nextInt() % 500) + 1 + long bookId = Math.abs(random.nextInt() % 1500) + 1 + if(seen.add([authorId, bookId])) { + Author a = Author.load(authorId) + Book b = Book.load(bookId) + if(a && b) { + new BookAuthor(book: b, author: a).save() + count++ + } + if(count % 500 == 0) { + datastore.sessionFactory.currentSession.flush() + datastore.sessionFactory.currentSession.clear() + } } - datastore.sessionFactory.currentSession.flush() - datastore.sessionFactory.currentSession.clear() } + datastore.sessionFactory.currentSession.flush() + datastore.sessionFactory.currentSession.clear() } void 'test read performance with join query'() {
