You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@grails.apache.org by bo...@apache.org on 2026/10/20 00:46:38 UTC
(grails-core) branch groovyism/hibernate7 created (now 54cd07b7a7)
This is an automated email from the ASF dual-hosted git repository.
borinquenkid pushed a change to branch groovyism/hibernate7
in repository https://gitbox.apache.org/repos/asf/grails-core.git
at 54cd07b7a7 CHANGEME FOR ACCEPTANCE: disable PR workflow triggers on stacked PRs (revert before merge)
This branch includes the following new commits:
new e8cdac47f6 refactor(hibernate7): idiomatic Groovy cleanup, partial (31 of ~435 files)
new 8bf8ac1be0 wip(groovyism): checkpoint uncommitted idiomatic cleanup before merging H7 stage-2 tip
new dd40513f71 Merge refactor/java-to-groovy-grails-data-hibernate7 into groovyism/hibernate7
new 54cd07b7a7 CHANGEME FOR ACCEPTANCE: disable PR workflow triggers on stacked PRs (revert before merge)
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(grails-core) 04/04: CHANGEME FOR ACCEPTANCE: disable PR workflow triggers on stacked PRs (revert before merge)
Posted by bo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
borinquenkid pushed a commit to branch groovyism/hibernate7
in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit 54cd07b7a74eb206d8d604434e5f07cb3d04c17a
Author: Walter Duque de Estrada <wb...@mac.com>
AuthorDate: Mon Oct 19 19:42:08 2026 -0500
CHANGEME FOR ACCEPTANCE: disable PR workflow triggers on stacked PRs (revert before merge)
Pushes, rebases and force-pushes to this stacked PR start no jobs; the PR closest to the release branch keeps CI.
Merging with this commit is a blocker.
Co-Authored-By: Claude Sonnet 5.5 <no...@anthropic.com>
---
.github/workflows/benchmark.yml | 7 ++-----
.github/workflows/build-health.yml | 2 ++
.github/workflows/codeanalysis.yml | 2 ++
.github/workflows/codeql.yml | 6 ++----
.github/workflows/codestyle.yml | 2 ++
.github/workflows/coverage.yml | 2 ++
.github/workflows/end-to-end.yml | 2 ++
.github/workflows/gradle.yml | 2 ++
.github/workflows/groovy-snapshot-canary.yml | 4 ++--
.github/workflows/rat.yml | 5 ++---
.github/workflows/sitemesh2.yml | 8 ++------
.github/workflows/validate-actions.yml | 6 ++----
.github/workflows/vulnerability-scan.yml | 3 ++-
13 files changed, 26 insertions(+), 25 deletions(-)
diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml
index 53e88c886a..dd1e1c37c7 100644
--- a/.github/workflows/benchmark.yml
+++ b/.github/workflows/benchmark.yml
@@ -20,11 +20,8 @@ name: "JMH Benchmark Comparison"
# to that code through a privileged pull_request_target workflow.
on:
pull_request:
- types: [opened, synchronize, reopened, labeled]
- paths-ignore:
- - '**/*.md'
- - '**/*.adoc'
- - 'grails-doc/**'
+ # CHANGEME FOR ACCEPTANCE: PR triggers disabled on this stacked branch; revert before merge
+ branches: ['CHANGEME-FOR-ACCEPTANCE']
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}-${{ github.event.action == 'labeled' && github.event.label.name != 'performance' && github.run_id || 'benchmark' }}
diff --git a/.github/workflows/build-health.yml b/.github/workflows/build-health.yml
index a8564b0c35..fa303225ba 100644
--- a/.github/workflows/build-health.yml
+++ b/.github/workflows/build-health.yml
@@ -19,6 +19,8 @@ on:
branches:
- '[0-9]+.[0-9]+.x'
pull_request:
+ # CHANGEME FOR ACCEPTANCE: PR triggers disabled on this stacked branch; revert before merge
+ branches: ['CHANGEME-FOR-ACCEPTANCE']
workflow_dispatch:
# queue jobs and only allow 1 run per branch due to the likelihood of hitting GitHub resource limits
concurrency:
diff --git a/.github/workflows/codeanalysis.yml b/.github/workflows/codeanalysis.yml
index d370384dd7..cb560cd9b3 100644
--- a/.github/workflows/codeanalysis.yml
+++ b/.github/workflows/codeanalysis.yml
@@ -20,6 +20,8 @@ on:
- '[0-9]+.[0-9]+.x'
- '8.0.x-hibernate7.*'
pull_request:
+ # CHANGEME FOR ACCEPTANCE: PR triggers disabled on this stacked branch; revert before merge
+ branches: ['CHANGEME-FOR-ACCEPTANCE']
workflow_dispatch:
# queue jobs and only allow 1 run per branch due to the likelihood of hitting GitHub resource limits
concurrency:
diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml
index d72fca1f37..6459eebb07 100644
--- a/.github/workflows/codeql.yml
+++ b/.github/workflows/codeql.yml
@@ -32,10 +32,8 @@ on:
- '[4-9]+.[0-9]+.x'
- '8.0.x-hibernate7.*'
pull_request:
- # The branches below must be a subset of the branches above
- branches:
- - '[4-9]+.[0-9]+.x'
- - '8.0.x-hibernate7.*'
+ # CHANGEME FOR ACCEPTANCE: PR triggers disabled on this stacked branch; revert before merge
+ branches: ['CHANGEME-FOR-ACCEPTANCE']
# queue jobs and only allow 1 run per branch due to the likelihood of hitting GitHub resource limits
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
diff --git a/.github/workflows/codestyle.yml b/.github/workflows/codestyle.yml
index d5e14ee8ad..5af095573f 100644
--- a/.github/workflows/codestyle.yml
+++ b/.github/workflows/codestyle.yml
@@ -20,6 +20,8 @@ on:
- '[0-9]+.[0-9]+.x'
- '8.0.x-hibernate7.*'
pull_request:
+ # CHANGEME FOR ACCEPTANCE: PR triggers disabled on this stacked branch; revert before merge
+ branches: ['CHANGEME-FOR-ACCEPTANCE']
workflow_dispatch:
# queue jobs and only allow 1 run per branch due to the likelihood of hitting GitHub resource limits
concurrency:
diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml
index bcfb02719f..efe587199c 100644
--- a/.github/workflows/coverage.yml
+++ b/.github/workflows/coverage.yml
@@ -21,6 +21,8 @@ on:
- '[0-9]+.[0-9]+.x'
- '8.0.x-hibernate7.*'
pull_request:
+ # CHANGEME FOR ACCEPTANCE: PR triggers disabled on this stacked branch; revert before merge
+ branches: ['CHANGEME-FOR-ACCEPTANCE']
workflow_dispatch:
concurrency:
diff --git a/.github/workflows/end-to-end.yml b/.github/workflows/end-to-end.yml
index 3986680e06..80917897cd 100644
--- a/.github/workflows/end-to-end.yml
+++ b/.github/workflows/end-to-end.yml
@@ -38,6 +38,8 @@ on:
branches:
- '[0-9]+.[0-9]+.x'
pull_request:
+ # CHANGEME FOR ACCEPTANCE: PR triggers disabled on this stacked branch; revert before merge
+ branches: ['CHANGEME-FOR-ACCEPTANCE']
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml
index 82692baefe..0725433ae8 100644
--- a/.github/workflows/gradle.yml
+++ b/.github/workflows/gradle.yml
@@ -19,6 +19,8 @@ on:
branches:
- '[0-9]+.[0-9]+.x'
pull_request:
+ # CHANGEME FOR ACCEPTANCE: PR triggers disabled on this stacked branch; revert before merge
+ branches: ['CHANGEME-FOR-ACCEPTANCE']
workflow_dispatch:
# Queue jobs - cancel in-progress PR runs when new commits pushed, but allow branch builds to complete
concurrency:
diff --git a/.github/workflows/groovy-snapshot-canary.yml b/.github/workflows/groovy-snapshot-canary.yml
index c795d9db26..dd97156a71 100644
--- a/.github/workflows/groovy-snapshot-canary.yml
+++ b/.github/workflows/groovy-snapshot-canary.yml
@@ -19,8 +19,8 @@ on:
branches:
- '[0-9]+.[0-9]+.x'
pull_request:
- branches:
- - '[0-9]+.[0-9]+.x'
+ # CHANGEME FOR ACCEPTANCE: PR triggers disabled on this stacked branch; revert before merge
+ branches: ['CHANGEME-FOR-ACCEPTANCE']
workflow_dispatch:
# queue jobs and only allow 1 run per branch due to the likelihood of hitting GitHub resource limits
concurrency:
diff --git a/.github/workflows/rat.yml b/.github/workflows/rat.yml
index f13a580f68..42d724ce9a 100644
--- a/.github/workflows/rat.yml
+++ b/.github/workflows/rat.yml
@@ -20,9 +20,8 @@ on:
- '[0-9]+.[0-9]+.x'
- '8.0.x-hibernate7.*'
pull_request:
- branches:
- - '[0-9]+.[0-9]+.x'
- - '8.0.x-hibernate7.*'
+ # CHANGEME FOR ACCEPTANCE: PR triggers disabled on this stacked branch; revert before merge
+ branches: ['CHANGEME-FOR-ACCEPTANCE']
workflow_dispatch:
# queue jobs and only allow 1 run per branch due to the likelihood of hitting GitHub resource limits
concurrency:
diff --git a/.github/workflows/sitemesh2.yml b/.github/workflows/sitemesh2.yml
index 2c9b81232d..e4469b4f6b 100644
--- a/.github/workflows/sitemesh2.yml
+++ b/.github/workflows/sitemesh2.yml
@@ -34,12 +34,8 @@ on:
- 'grails-dependencies/**'
- '.github/workflows/sitemesh2.yml'
pull_request:
- paths:
- - 'grails-gsp/**'
- - 'grails-test-suite-uber/**'
- - 'grails-test-examples/**'
- - 'grails-dependencies/**'
- - '.github/workflows/sitemesh2.yml'
+ # CHANGEME FOR ACCEPTANCE: PR triggers disabled on this stacked branch; revert before merge
+ branches: ['CHANGEME-FOR-ACCEPTANCE']
# Queue jobs - cancel in-progress PR runs when new commits pushed, but allow branch builds to complete
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
diff --git a/.github/workflows/validate-actions.yml b/.github/workflows/validate-actions.yml
index eaad416c08..70fe0b5e61 100644
--- a/.github/workflows/validate-actions.yml
+++ b/.github/workflows/validate-actions.yml
@@ -24,10 +24,8 @@ on:
- 'build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/ValidateActionsTask.groovy'
- 'build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/GrailsValidateActionsPlugin.groovy'
pull_request:
- paths:
- - '.github/workflows/**'
- - 'build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/ValidateActionsTask.groovy'
- - 'build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/GrailsValidateActionsPlugin.groovy'
+ # CHANGEME FOR ACCEPTANCE: PR triggers disabled on this stacked branch; revert before merge
+ branches: ['CHANGEME-FOR-ACCEPTANCE']
schedule:
- cron: '0 6 * * 1' # weekly Monday 06:00 UTC — catches ASF delisting a pinned SHA
workflow_dispatch:
diff --git a/.github/workflows/vulnerability-scan.yml b/.github/workflows/vulnerability-scan.yml
index 147775b932..9824ebb714 100644
--- a/.github/workflows/vulnerability-scan.yml
+++ b/.github/workflows/vulnerability-scan.yml
@@ -22,7 +22,8 @@ on:
# Opt in per pull request by applying the "vulnerability scan" label. Applying a label
# requires write access, so only a committer can start a scan.
pull_request:
- types: [labeled, synchronize, reopened]
+ # CHANGEME FOR ACCEPTANCE: PR triggers disabled on this stacked branch; revert before merge
+ branches: ['CHANGEME-FOR-ACCEPTANCE']
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
(grails-core) 01/04: refactor(hibernate7): idiomatic Groovy cleanup, partial (31 of ~435 files)
Posted by bo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
borinquenkid pushed a commit to branch groovyism/hibernate7
in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit e8cdac47f6f817a9a19f226a24aa709a8fe0ede2
Author: Walter Duque de Estrada <wb...@mac.com>
AuthorDate: Fri Oct 16 21:24:03 2026 -0500
refactor(hibernate7): idiomatic Groovy cleanup, partial (31 of ~435 files)
Behaviour-preserving idiom pass over 31 files in grails-data-hibernate7-core
(binders, query/criteria classes, event listeners, cfg classes). This is a
CHECKPOINT, not the full scope for this module - the remaining ~404 converted
files in the H7 stack are not yet covered.
Verification: compileGroovy/compileTestGroovy clean; codenarcMain clean except
a pre-existing CodeNarc internal crash on SqlRestriction.groovy's record class
(confirmed via diffing against the untouched original - same crash there,
unrelated to this change, Gradle still reports codenarcMain BUILD SUCCESSFUL);
full grails-data-hibernate7-core test suite: 4300 tests, 1 failure (Oracle
testcontainer OOM-killed by Docker, an infrastructure flake, not a regression
from this change), 8 skipped.
Co-Authored-By: Claude Sonnet 5 <no...@anthropic.com>
---
.../groovy/grails/orm/CriteriaMethodInvoker.groovy | 2 +-
.../grails/orm/HibernateCriteriaBuilder.groovy | 2 +-
.../CloseSuppressingInvocationHandler.groovy | 2 +-
.../orm/hibernate/EventListenerIntegrator.groovy | 2 +-
.../grails/orm/hibernate/HibernateDatastore.groovy | 8 ++++----
.../org/grails/orm/hibernate/HibernateSession.groovy | 8 ++++----
.../orm/hibernate/cfg/GrailsHibernateUtil.groovy | 2 +-
.../orm/hibernate/cfg/HibernateMappingContext.groovy | 2 +-
.../cfg/HibernateMappingContextConfiguration.groovy | 6 +++---
.../grails/orm/hibernate/cfg/IdentityEnumType.groovy | 8 ++++----
.../orm/hibernate/cfg/MappingCacheHolder.groovy | 2 +-
.../column/NumericColumnConstraintsBinder.groovy | 8 ++++----
.../hibernate/GrailsHibernatePersistentEntity.groovy | 4 ++--
.../hibernate/HibernatePersistentProperty.groovy | 6 +++---
.../cfg/domainbinding/jpa/CollectionKind.groovy | 6 +-----
.../jpa/GeneratedDomainClassBinder.groovy | 10 +++++-----
.../domainbinding/jpa/GrailsDomainGenerator.groovy | 20 ++++++++++----------
.../jpa/ManyToManyOwnerValidator.groovy | 2 +-
.../cfg/domainbinding/util/CreateKeyForProps.groovy | 4 ++--
.../HibernateConnectionSourceFactory.groovy | 4 ++--
.../event/listener/HibernateEventListener.groovy | 8 ++++----
.../multitenancy/MultiTenantEventListener.groovy | 2 +-
.../query/DetachedAssociationFunction.groovy | 2 +-
.../grails/orm/hibernate/query/HibernateQuery.groovy | 2 +-
.../hibernate/query/HibernateQueryExecutor.groovy | 2 +-
.../orm/hibernate/query/HqlListQueryBuilder.groovy | 2 +-
.../orm/hibernate/query/HqlQueryContext.groovy | 8 ++++----
.../orm/hibernate/query/JpaProjectionAdapter.groovy | 2 +-
.../orm/hibernate/query/JpaQueryContext.groovy | 4 ++--
.../grails/orm/hibernate/query/SqlRestriction.groovy | 4 ++--
.../hibernate/support/ClosureEventListener.groovy | 2 +-
31 files changed, 71 insertions(+), 75 deletions(-)
diff --git a/grails-data-hibernate7/core/src/main/groovy/grails/orm/CriteriaMethodInvoker.groovy b/grails-data-hibernate7/core/src/main/groovy/grails/orm/CriteriaMethodInvoker.groovy
index 3392c02c36..e8c0dc88a4 100644
--- a/grails-data-hibernate7/core/src/main/groovy/grails/orm/CriteriaMethodInvoker.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/grails/orm/CriteriaMethodInvoker.groovy
@@ -150,7 +150,7 @@ class CriteriaMethodInvoker {
Object ignoreCaseValue = argMap.get(HibernateQueryArgument.IGNORE_CASE.value())
final boolean ignoreCase = !(ignoreCaseValue instanceof Boolean) || (Boolean) ignoreCaseValue
DynamicFinder.validateSortProperty(hibernateQuery.getEntity(), sortField)
- final Query.Order order = DynamicFinder.ORDER_DESC.equals(direction) ?
+ final Query.Order order = DynamicFinder.ORDER_DESC == direction ?
Query.Order.desc(sortField) :
Query.Order.asc(sortField)
if (ignoreCase) {
diff --git a/grails-data-hibernate7/core/src/main/groovy/grails/orm/HibernateCriteriaBuilder.groovy b/grails-data-hibernate7/core/src/main/groovy/grails/orm/HibernateCriteriaBuilder.groovy
index be2e524bd4..23368d42cd 100644
--- a/grails-data-hibernate7/core/src/main/groovy/grails/orm/HibernateCriteriaBuilder.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/grails/orm/HibernateCriteriaBuilder.groovy
@@ -966,7 +966,7 @@ class HibernateCriteriaBuilder extends GroovyObjectSupport implements BuildableC
* @return A Criterion instance
*/
Criteria eq(String propertyName, Object propertyValue, Map<?, ?> params) {
- if (Boolean.TRUE.equals(params.get('ignoreCase')) && propertyValue instanceof CharSequence) {
+ if (Boolean.TRUE == params['ignoreCase'] && propertyValue instanceof CharSequence) {
hibernateQuery.eqIgnoreCase(propertyName, propertyValue.toString())
}
else {
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/CloseSuppressingInvocationHandler.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/CloseSuppressingInvocationHandler.groovy
index f55097ddca..b06e0d43d6 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/CloseSuppressingInvocationHandler.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/CloseSuppressingInvocationHandler.groovy
@@ -49,7 +49,7 @@ class CloseSuppressingInvocationHandler implements InvocationHandler {
switch (method.name) {
case 'equals':
// Only consider equal when proxies are identical.
- return Objects.equals(proxy, args[0])
+ return proxy == args[0]
case 'hashCode':
// Use hashCode of Session proxy.
return System.identityHashCode(proxy)
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/EventListenerIntegrator.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/EventListenerIntegrator.groovy
index 8200b1e240..94b2e6f53e 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/EventListenerIntegrator.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/EventListenerIntegrator.groovy
@@ -188,7 +188,7 @@ class EventListenerIntegrator implements Integrator {
*/
@SuppressWarnings('unchecked')
private <T> List<T> grailsOwnedListeners(EventListenerGroup<T> group, T replacement) {
- List<T> retained = new ArrayList<>()
+ List<T> retained = []
if (group == null || group.listeners() == null) {
return retained
}
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/HibernateDatastore.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/HibernateDatastore.groovy
index e67697425f..da53bc6623 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/HibernateDatastore.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/HibernateDatastore.groovy
@@ -206,7 +206,7 @@ class HibernateDatastore extends AbstractDatastore
protected final GrailsHibernateTransactionManager transactionManager
protected final ConfigurableApplicationEventPublisher eventPublisher
protected final HibernateGormEnhancer gormEnhancer
- protected final Map<String, HibernateDatastore> datastoresByConnectionSource = Collections.synchronizedMap(new LinkedHashMap<>())
+ protected final Map<String, HibernateDatastore> datastoresByConnectionSource = Collections.synchronizedMap([:])
private final List<ConnectionSource<SessionFactory, HibernateConnectionSourceSettings>> schemaTenantConnectionSources = new CopyOnWriteArrayList<>()
protected final Metadata metadata
protected final GrailsBytecodeProvider bytecodeProvider
@@ -576,7 +576,7 @@ class HibernateDatastore extends AbstractDatastore
super.setApplicationContext(applicationContext)
for (HibernateDatastore hibernateDatastore : datastoresByConnectionSource.values()) {
- if (!Objects.equals(hibernateDatastore, this)) {
+ if (hibernateDatastore != this) {
hibernateDatastore.setApplicationContext(applicationContext)
}
}
@@ -620,7 +620,7 @@ class HibernateDatastore extends AbstractDatastore
previousMode = session.hibernateFlushMode
session.setHibernateFlushMode(flushMode)
}
- reset = !Boolean.FALSE.equals(callable.call())
+ reset = callable.call() != Boolean.FALSE
} catch (Exception e) {
ReflectionUtils.rethrowRuntimeException(e)
} finally {
@@ -801,7 +801,7 @@ class HibernateDatastore extends AbstractDatastore
schemaHandler.useDefaultSchema(connection)
} catch (SQLException e) {
throw new DatastoreConfigurationException(
- String.format('Failed to create schema for name [%s]', schemaName), e)
+ "Failed to create schema for name [${schemaName}]".toString(), e)
}
}
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/HibernateSession.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/HibernateSession.groovy
index fa596b0c81..8dba9fbca6 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/HibernateSession.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/HibernateSession.groovy
@@ -316,7 +316,7 @@ class HibernateSession extends AbstractAttributeStoringSession implements QueryA
MutationQuery query = createMutationQuery(session, jpaQueryInfo)
- HqlQueryContext ctx = HqlQueryContext.prepare(criteria.persistentEntity, jpaQueryInfo.query, null, null, null, new HashMap<>(), false, true)
+ HqlQueryContext ctx = HqlQueryContext.prepare(criteria.persistentEntity, jpaQueryInfo.query, null, null, null, [:], false, true)
MutationHqlQuery hqlQuery = (MutationHqlQuery) HibernateHqlQueryCreator.createHqlQuery((HibernateDatastore) getDatastore(), hibernateTemplate.sessionFactory, criteria.persistentEntity, ctx)
ApplicationEventPublisher applicationEventPublisher = datastore.applicationEventPublisher
applicationEventPublisher.publishEvent(new PreQueryEvent(datastore, hqlQuery))
@@ -367,7 +367,7 @@ class HibernateSession extends AbstractAttributeStoringSession implements QueryA
MutationQuery query = createMutationQuery(session, jpaQueryInfo)
- HqlQueryContext ctx = HqlQueryContext.prepare(targetEntity, jpaQueryInfo.query, null, null, null, new HashMap<>(), false, true)
+ HqlQueryContext ctx = HqlQueryContext.prepare(targetEntity, jpaQueryInfo.query, null, null, null, [:], false, true)
MutationHqlQuery hqlQuery = (MutationHqlQuery) HibernateHqlQueryCreator.createHqlQuery((HibernateDatastore) getDatastore(), hibernateTemplate.sessionFactory, targetEntity, ctx)
ApplicationEventPublisher applicationEventPublisher = datastore.applicationEventPublisher
applicationEventPublisher.publishEvent(new PreQueryEvent(datastore, hqlQuery))
@@ -399,7 +399,7 @@ class HibernateSession extends AbstractAttributeStoringSession implements QueryA
return getHibernateTemplate().execute({ Session session ->
// Query only the distinct, non-null ids; a missing id simply yields no row.
- Set<Serializable> distinctIds = new LinkedHashSet<>()
+ Set<Serializable> distinctIds = [] as Set
for (Serializable requestedId : requestedIds) {
if (requestedId != null) {
distinctIds.add(requestedId)
@@ -419,7 +419,7 @@ class HibernateSession extends AbstractAttributeStoringSession implements QueryA
(Map<String, Object>) Map.of('keys', distinctIds),
(Collection<Object>) null,
(Map<String, Object>) null,
- new HashMap<>(),
+ [:],
false,
false,
type
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/GrailsHibernateUtil.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/GrailsHibernateUtil.groovy
index 64b66b7119..bc4004a919 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/GrailsHibernateUtil.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/GrailsHibernateUtil.groovy
@@ -184,7 +184,7 @@ class GrailsHibernateUtil extends HibernateRuntimeUtils {
*/
static void ensureCorrectGroovyMetaClass(Object target, Class<?> persistentClass) {
if (target instanceof GroovyObject) {
- if (!target.metaClass.theClass.equals(persistentClass)) {
+ if (target.metaClass.theClass != persistentClass) {
target.metaClass = GroovySystem.metaClassRegistry.getMetaClass(persistentClass)
}
}
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/HibernateMappingContext.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/HibernateMappingContext.groovy
index c2f20a02a2..858298bfab 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/HibernateMappingContext.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/HibernateMappingContext.groovy
@@ -122,7 +122,7 @@ class HibernateMappingContext extends AbstractMappingContext {
}
List<HibernatePersistentEntity> getHibernatePersistentEntities() {
- List<HibernatePersistentEntity> result = new ArrayList<>()
+ List<HibernatePersistentEntity> result = []
for (PersistentEntity entity : persistentEntities) {
if (entity instanceof HibernatePersistentEntity) {
result.add(entity)
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/HibernateMappingContextConfiguration.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/HibernateMappingContextConfiguration.groovy
index f229cec390..93c50f9578 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/HibernateMappingContextConfiguration.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/HibernateMappingContextConfiguration.groovy
@@ -101,7 +101,7 @@ class HibernateMappingContextConfiguration extends Configuration
// dependency of this module
private static final String ENVERS_DO_NOT_AUDIT_OPTIMISTIC_LOCKING_FIELD = 'org.hibernate.envers.do_not_audit_optimistic_locking_field'
private final Class<? extends CurrentSessionContext> currentSessionContext = GrailsSessionContext
- private final Set<Class> additionalClasses = new HashSet<>()
+ private final Set<Class> additionalClasses = [] as Set
protected String sessionFactoryBeanName = 'sessionFactory'
protected String dataSourceName = ConnectionSource.DEFAULT
protected transient HibernateMappingContext hibernateMappingContext
@@ -135,7 +135,7 @@ class HibernateMappingContextConfiguration extends Configuration
@Override
void setApplicationContext(@Nullable ApplicationContext applicationContext) throws BeansException {
resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(applicationContext)
- String dsName = ConnectionSource.DEFAULT.equals(dataSourceName) ? 'dataSource' : "dataSource_${dataSourceName}"
+ String dsName = ConnectionSource.DEFAULT == dataSourceName ? 'dataSource' : "dataSource_${dataSourceName}"
Properties properties = getProperties()
if (applicationContext != null) {
@@ -299,7 +299,7 @@ class HibernateMappingContextConfiguration extends Configuration
ConfigurationHelper.resolvePlaceHolders(properties)
- List<Class> annotatedClasses = new ArrayList<>()
+ List<Class> annotatedClasses = []
for (PersistentEntity persistentEntity : hibernateMappingContext.persistentEntities) {
Class<?> javaClass = persistentEntity.javaClass
if (javaClass.isAnnotationPresent(Entity)) {
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/IdentityEnumType.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/IdentityEnumType.groovy
index 47dc3ae6a4..c8be1ecad9 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/IdentityEnumType.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/IdentityEnumType.groovy
@@ -53,7 +53,7 @@ class IdentityEnumType implements UserType<Object>, ParameterizedType, Serializa
public static final String ENUM_ID_ACCESSOR = 'getId'
public static final String PARAM_ENUM_CLASS = 'enumClass'
- private static final Map<Class<? extends Enum<?>>, BidiEnumMap> ENUM_MAPPINGS = new HashMap<>()
+ private static final Map<Class<? extends Enum<?>>, BidiEnumMap> ENUM_MAPPINGS = [:]
protected Class<? extends Enum<?>> enumClass
protected BidiEnumMap bidiMap
@@ -62,10 +62,10 @@ class IdentityEnumType implements UserType<Object>, ParameterizedType, Serializa
protected int sqlType
static BidiEnumMap getBidiEnumMap(Class<? extends Enum<?>> cls) {
- BidiEnumMap m = ENUM_MAPPINGS.get(cls)
+ BidiEnumMap m = ENUM_MAPPINGS[cls]
if (m == null) {
synchronized (ENUM_MAPPINGS) {
- m = ENUM_MAPPINGS.get(cls)
+ m = ENUM_MAPPINGS[cls]
if (m == null) {
try {
m = new BidiEnumMap(cls)
@@ -138,7 +138,7 @@ class IdentityEnumType implements UserType<Object>, ParameterizedType, Serializa
@Override
boolean equals(Object x, Object y) throws HibernateException {
- return x == y || (x != null && y != null && x.equals(y))
+ return x == y
}
@Override
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/MappingCacheHolder.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/MappingCacheHolder.groovy
index 3b1672a24d..f12318cd6c 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/MappingCacheHolder.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/MappingCacheHolder.groovy
@@ -26,7 +26,7 @@ import org.grails.orm.hibernate.cfg.domainbinding.hibernate.GrailsHibernatePersi
@CompileStatic
class MappingCacheHolder {
- private final Map<Class<?>, Mapping> mappingCache = new HashMap<>()
+ private final Map<Class<?>, Mapping> mappingCache = [:]
/**
* Obtains a mapping object for the given domain class nam
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/column/NumericColumnConstraintsBinder.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/column/NumericColumnConstraintsBinder.groovy
index d59f237b71..e8927e180a 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/column/NumericColumnConstraintsBinder.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/column/NumericColumnConstraintsBinder.groovy
@@ -74,10 +74,10 @@ class NumericColumnConstraintsBinder {
}
private boolean isApproximateFloatingPoint(Class<?> propertyType) {
- return Float.equals(propertyType) ||
- float.class.equals(propertyType) ||
- Double.equals(propertyType) ||
- double.class.equals(propertyType)
+ return Float == propertyType ||
+ float.class == propertyType ||
+ Double == propertyType ||
+ double.class == propertyType
}
private int getConstraintValueLength(Comparable<?> min, int scale) {
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/GrailsHibernatePersistentEntity.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/GrailsHibernatePersistentEntity.groovy
index 0aa81130ae..b6f9695ef4 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/GrailsHibernatePersistentEntity.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/GrailsHibernatePersistentEntity.groovy
@@ -106,8 +106,8 @@ interface GrailsHibernatePersistentEntity extends PersistentEntity {
String quotedDiscriminator = quote + discriminatorValue + quote
- Set<String> result = new LinkedHashSet<>()
- result.add(quotedDiscriminator)
+ Set<String> result = [] as Set
+ result << quotedDiscriminator
for (GrailsHibernatePersistentEntity child : childEntities) {
result.addAll(child.buildDiscriminatorSet())
}
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernatePersistentProperty.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernatePersistentProperty.groovy
index 54803198d7..94a3d4fb1d 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernatePersistentProperty.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernatePersistentProperty.groovy
@@ -170,7 +170,7 @@ interface HibernatePersistentProperty extends PersistentProperty<PropertyConfig>
@Override
default boolean isLazyAble() {
return this instanceof HibernateAssociation ||
- !(this instanceof Embedded) && !this.equals(this.getOwner().getIdentity())
+ !(this instanceof Embedded) && this != this.getOwner().getIdentity()
}
/**
@@ -292,9 +292,9 @@ interface HibernatePersistentProperty extends PersistentProperty<PropertyConfig>
if (typeParams == null || typeParams.isEmpty()) {
return Optional.<HibernateSimpleIdentity>empty()
}
- Map<String, String> params = new LinkedHashMap<>()
+ Map<String, String> params = [:]
for (Map.Entry<Object, Object> entry : typeParams.entrySet()) {
- params.put(entry.getKey().toString(), entry.getValue().toString())
+ params.put(entry.key.toString(), entry.value.toString())
}
HibernateSimpleIdentity identity = new HibernateSimpleIdentity()
identity.setName(getName())
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/jpa/CollectionKind.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/jpa/CollectionKind.groovy
index 7a0a7505de..2bb8218ff8 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/jpa/CollectionKind.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/jpa/CollectionKind.groovy
@@ -37,16 +37,12 @@ enum CollectionKind {
MAP(Map),
SORTED_SET(SortedSet)
- private final Class<?> javaType
+ final Class<?> javaType
CollectionKind(Class<?> javaType) {
this.javaType = javaType
}
- Class<?> getJavaType() {
- return javaType
- }
-
/** @return the kind for the exact declared type, or {@code null} when the binder has no collection for it */
static CollectionKind of(Class<?> type) {
return values().find { CollectionKind kind -> kind.javaType == type }
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/jpa/GeneratedDomainClassBinder.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/jpa/GeneratedDomainClassBinder.groovy
index ff6a19e672..d5f72e801e 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/jpa/GeneratedDomainClassBinder.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/jpa/GeneratedDomainClassBinder.groovy
@@ -117,7 +117,7 @@ class GeneratedDomainClassBinder implements SessionFactoryBuilderFactory {
private final String dataSourceName
private final GeneratedDomainClassLoader classLoader
private final PropertyAccessorName propertyAccessorName = new PropertyAccessorName()
- private final Map<String, Generated> generatedByName = new HashMap<String, Generated>()
+ private final Map<String, Generated> generatedByName = [:]
private final MultiTenantFilterDefinitionBinder filterDefinitionBinder = new MultiTenantFilterDefinitionBinder()
private final UniqueNameGenerator uniqueNameGenerator = new UniqueNameGenerator()
private PersistentEntityNamingStrategy namingStrategy
@@ -218,7 +218,7 @@ class GeneratedDomainClassBinder implements SessionFactoryBuilderFactory {
// the mappings are bound: from here on the domain class names resolve to the real classes
classLoaderService?.useRealClasses()
for (PersistentClass persistentClass : new ArrayList<PersistentClass>(metadata.entityBindings)) {
- Generated generated = generatedByName.get(persistentClass.className)
+ Generated generated = generatedByName[persistentClass.className]
if (generated != null) {
align(persistentClass, generated, metadata)
}
@@ -505,8 +505,8 @@ class GeneratedDomainClassBinder implements SessionFactoryBuilderFactory {
*/
private void alignCompositeForeignKeys(MetadataImplementor metadata) {
for (PersistentClass persistentClass : new ArrayList<PersistentClass>(metadata.entityBindings)) {
- if (generatedByName.containsKey(persistentClass.entityName)) {
- List<Value> values = new ArrayList<Value>()
+ if (persistentClass.entityName in generatedByName) {
+ List<Value> values = []
collectValues(persistentClass, values)
for (Value value : values) {
if (value instanceof ManyToOne) {
@@ -539,7 +539,7 @@ class GeneratedDomainClassBinder implements SessionFactoryBuilderFactory {
}
private void alignCompositeForeignKey(ManyToOne value) {
- Generated target = generatedByName.get(value.referencedEntityName)
+ Generated target = generatedByName[value.referencedEntityName]
if (target == null || target.entity().compositeIdentity == null) {
return
}
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/jpa/GrailsDomainGenerator.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/jpa/GrailsDomainGenerator.groovy
index 1fc694b0c4..9ae60d774a 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/jpa/GrailsDomainGenerator.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/jpa/GrailsDomainGenerator.groovy
@@ -211,10 +211,10 @@ class GrailsDomainGenerator {
private final ForeignKeyColumnCountCalculator foreignKeyColumnCount = new ForeignKeyColumnCountCalculator()
/** The collections of embedded types that more than one embedded property reaches, as {@code <embedded class>#<collection>}. */
- private Set<String> sharedEmbeddedCollections = new HashSet<String>()
+ private Set<String> sharedEmbeddedCollections = [] as Set
/** For each such collection, the qualifier of the embedded properties that do not keep the binder's names, by {@link #embeddedUseKey}. */
- private Map<String, String> embeddedCollectionQualifiers = new HashMap<String, String>()
+ private Map<String, String> embeddedCollectionQualifiers = [:]
GrailsDomainGenerator(
PersistentEntityNamingStrategy namingStrategy,
@@ -328,7 +328,7 @@ class GrailsDomainGenerator {
* qualified with the table of their owner and the path of their embedded property ({@link #embeddedCollectionQualifier}).</p>
*/
private void assignEmbeddedCollectionQualifiers(Collection<GrailsHibernatePersistentEntity> entities) {
- Map<String, List<EmbeddedUse>> uses = new LinkedHashMap<String, List<EmbeddedUse>>()
+ Map<String, List<EmbeddedUse>> uses = [:]
for (GrailsHibernatePersistentEntity entity : entities) {
for (HibernatePersistentProperty property : entity.persistentPropertiesToBind) {
if (isComponent(property)) {
@@ -336,8 +336,8 @@ class GrailsDomainGenerator {
}
}
}
- Set<String> shared = new HashSet<String>()
- Map<String, String> qualifiers = new HashMap<String, String>()
+ Set<String> shared = [] as Set
+ Map<String, String> qualifiers = [:]
for (Map.Entry<String, List<EmbeddedUse>> entry : uses.entrySet()) {
// an embedded type that is an entity too has a collection of its own, bound under the binder's names, so every embedded use is qualified
String typeName = entry.key.substring(0, entry.key.indexOf('#'))
@@ -374,7 +374,7 @@ class GrailsDomainGenerator {
* first of those that reach it. Known after {@link #generateAll} has run.
*/
String embeddedCollectionQualifier(GrailsHibernatePersistentEntity owner, String path, String collection) {
- return embeddedCollectionQualifiers.get(embeddedUseKey(owner, path, collection))
+ return embeddedCollectionQualifiers[embeddedUseKey(owner, path, collection)]
}
private static void collectCollectionUses(
@@ -584,7 +584,7 @@ class GrailsDomainGenerator {
* identifier (a part that refers to an entity with a composite identifier makes the foreign key columns depend on the
* order {@code Component.sortProperties} gave the referenced key), and the entity must have no subclasses
*/
- private String compositeIdProblem(GrailsHibernatePersistentEntity entity, Set<String> visiting = new HashSet<String>()) {
+ private String compositeIdProblem(GrailsHibernatePersistentEntity entity, Set<String> visiting = [] as Set) {
if (!visiting.add(entity.name)) {
return "Entity [${entity.name}] has a composite identifier that refers to itself"
}
@@ -1146,13 +1146,13 @@ class GrailsDomainGenerator {
Map<String, String> parameters = [:]
if (isEnum) {
// the classic enum binder replaces the configured type parameters with the enum class
- parameters[IdentityEnumType.PARAM_ENUM_CLASS] = type.name
+ parameters.put(IdentityEnumType.PARAM_ENUM_CLASS, type.name)
} else if (!element) {
// the binder gives a collection element its type name only, never the type parameters
Properties typeParams = property.hibernateMappedForm.typeParams
if (typeParams != null) {
for (String key : new TreeSet<String>(typeParams.stringPropertyNames())) {
- parameters[key] = typeParams.getProperty(key)
+ parameters.put(key, typeParams.getProperty(key))
}
}
}
@@ -1285,7 +1285,7 @@ class GrailsDomainGenerator {
Properties properties = mappedId?.properties
if (properties != null) {
for (String key : new TreeSet<String>(properties.stringPropertyNames())) {
- parameters[key] = properties.getProperty(key)
+ parameters.put(key, properties.getProperty(key))
}
}
return new IdFacets(strategy, generatorClass(strategy), parameters)
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/jpa/ManyToManyOwnerValidator.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/jpa/ManyToManyOwnerValidator.groovy
index 58a102187b..542a1da1e6 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/jpa/ManyToManyOwnerValidator.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/jpa/ManyToManyOwnerValidator.groovy
@@ -48,7 +48,7 @@ class ManyToManyOwnerValidator {
if (!(property instanceof HibernateManyToManyProperty)) {
return
}
- HibernateManyToManyProperty manyToMany = (HibernateManyToManyProperty) property
+ HibernateManyToManyProperty manyToMany = property
if (!manyToMany.isBidirectional() || manyToMany.isOwningSide()) {
return
}
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/util/CreateKeyForProps.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/util/CreateKeyForProps.groovy
index 6eeb6455e7..404bc71283 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/util/CreateKeyForProps.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/util/CreateKeyForProps.groovy
@@ -59,8 +59,8 @@ class CreateKeyForProps {
if (mappedForm.isUnique() && mappedForm.isUniqueWithinGroup()) {
- List<Column> keyList = new ArrayList<>()
- keyList.add(new Column(columnName))
+ List<Column> keyList = []
+ keyList << new Column(columnName)
List<String> propertyNames = mappedForm.uniquenessGroup
GrailsHibernatePersistentEntity owner = grailsProp.hibernateOwner
for (String propertyName : propertyNames) {
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/connections/HibernateConnectionSourceFactory.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/connections/HibernateConnectionSourceFactory.groovy
index ad6b6f46f7..159fc39353 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/connections/HibernateConnectionSourceFactory.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/connections/HibernateConnectionSourceFactory.groovy
@@ -223,7 +223,7 @@ class HibernateConnectionSourceFactory
configuration.setHibernateMappingContext(mappingContext)
configuration.setDataSourceName(name)
configuration.setSessionFactoryBeanName(
- ConnectionSource.DEFAULT.equals(name) ? 'sessionFactory' : "sessionFactory_${name}")
+ ConnectionSource.DEFAULT == name ? 'sessionFactory' : "sessionFactory_${name}")
configuration.addProperties(settings.toProperties())
return configuration
}
@@ -249,7 +249,7 @@ class HibernateConnectionSourceFactory
HibernateMappingContextConfiguration configuration,
ConnectionSource<DataSource, DataSourceSettings> dataSourceConnectionSource) {
String dsName = dataSourceConnectionSource.name
- String beanName = ConnectionSource.DEFAULT.equals(dsName) ? 'dataSource' : "dataSource_${dsName}"
+ String beanName = ConnectionSource.DEFAULT == dsName ? 'dataSource' : "dataSource_${dsName}"
if (applicationContext != null && applicationContext.containsBean(beanName)) {
configuration.setApplicationContext(applicationContext)
}
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/event/listener/HibernateEventListener.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/event/listener/HibernateEventListener.groovy
index a787bf84af..540fa70457 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/event/listener/HibernateEventListener.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/event/listener/HibernateEventListener.groovy
@@ -221,20 +221,20 @@ class HibernateEventListener extends AbstractPersistenceEventListener {
Class<?> clazz = Hibernate.getClass(entity)
SoftKey<Class<?>> key = new SoftKey<Class<?>>(clazz)
- ClosureEventListener eventListener = eventListeners.get(key)
+ ClosureEventListener eventListener = eventListeners[key]
if (eventListener != null) {
return eventListener
}
- Boolean shouldTrigger = cachedShouldTrigger.get(key)
+ Boolean shouldTrigger = cachedShouldTrigger[key]
if (shouldTrigger == null || shouldTrigger) {
synchronized (cachedShouldTrigger) {
- eventListener = eventListeners.get(key)
+ eventListener = eventListeners[key]
if (eventListener == null) {
HibernateDatastore hibernateDatastore = getDatastore()
boolean isValidSessionFactory = MultiTenant.isAssignableFrom(clazz) ||
factory == null ||
- hibernateDatastore.getSessionFactory().equals(factory)
+ hibernateDatastore.sessionFactory == factory
HibernatePersistentEntity persistentEntity = (HibernatePersistentEntity) hibernateDatastore.getMappingContext().getPersistentEntity(clazz.getName())
shouldTrigger = (persistentEntity != null && isValidSessionFactory)
if (shouldTrigger) {
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/multitenancy/MultiTenantEventListener.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/multitenancy/MultiTenantEventListener.groovy
index 311de10bfa..89b61d07ae 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/multitenancy/MultiTenantEventListener.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/multitenancy/MultiTenantEventListener.groovy
@@ -87,7 +87,7 @@ class MultiTenantEventListener implements PersistenceEventListener {
Serializable currentId = Tenants.currentId(hibernateDatastore)
if (currentId != null) {
try {
- if (ConnectionSource.DEFAULT.equals(currentId)) {
+ if (ConnectionSource.DEFAULT == currentId) {
currentId = (Serializable) persistenceEvent.getEntityAccess().getProperty(tenantId.getName())
}
persistenceEvent.getEntityAccess().setProperty(tenantId.getName(), currentId)
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/DetachedAssociationFunction.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/DetachedAssociationFunction.groovy
index 2046e697c7..dd12424c77 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/DetachedAssociationFunction.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/DetachedAssociationFunction.groovy
@@ -35,7 +35,7 @@ class DetachedAssociationFunction implements Function<Query.Criterion, List<Deta
return List.of((DetachedAssociationCriteria<?>) o)
} else if (o instanceof Query.Junction) {
Query.Junction junction = (Query.Junction) o
- List<DetachedAssociationCriteria<?>> result = new ArrayList<>()
+ List<DetachedAssociationCriteria<?>> result = []
for (Query.Criterion criterion : junction.criteria) {
result.addAll(apply(criterion))
}
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/HibernateQuery.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/HibernateQuery.groovy
index ab5054f752..d0726c91e6 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/HibernateQuery.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/HibernateQuery.groovy
@@ -74,7 +74,7 @@ class HibernateQuery extends Query {
protected static final String ALIAS = '_alias'
private final Map<String, CriteriaAndAlias> createdAssociationPaths = [:]
private final List<HibernateAlias> aliases = []
- private final Set<String> fetchJoinPaths = new LinkedHashSet<>()
+ private final Set<String> fetchJoinPaths = [] as Set
protected String alias
protected int aliasCount
protected Deque<GrailsHibernatePersistentEntity> entityStack = new LinkedList<>()
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/HibernateQueryExecutor.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/HibernateQueryExecutor.groovy
index 2156c57619..11ecba4315 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/HibernateQueryExecutor.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/HibernateQueryExecutor.groovy
@@ -73,7 +73,7 @@ record HibernateQueryExecutor(
parameterValues.each { ParameterExpression<?> parameter, Object value ->
query.setParameter((Parameter<Object>) parameter, value)
}
- if (Tuple.equals(jpaCq.resultType)) {
+ if (Tuple == jpaCq.resultType) {
query.setTupleTransformer({ payload, aliases -> payload })
}
if (offset != null && offset > 0) {
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/HqlListQueryBuilder.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/HqlListQueryBuilder.groovy
index fb668bfe29..fba81d9693 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/HqlListQueryBuilder.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/HqlListQueryBuilder.groovy
@@ -52,7 +52,7 @@ class HqlListQueryBuilder {
if (fetchObj instanceof Map) {
Map<String, Object> fetchMap = (Map<String, Object>) fetchObj
for (Map.Entry<String, Object> entry : fetchMap.entrySet()) {
- if (HibernateQueryArgument.JOIN.value().equals(entry.value) || HibernateQueryArgument.EAGER.value().equals(entry.value)) {
+ if (HibernateQueryArgument.JOIN.value() == entry.value || HibernateQueryArgument.EAGER.value() == entry.value) {
requireMappedProperty(entry.key, HibernateQueryArgument.FETCH.value())
hql.append(' join fetch e.').append(entry.key)
}
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/HqlQueryContext.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/HqlQueryContext.groovy
index 9627e8d45e..21fac10acb 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/HqlQueryContext.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/HqlQueryContext.groovy
@@ -103,16 +103,16 @@ record HqlQueryContext(
boolean isUpdate,
Class<?> targetClassOverride) {
- Map<String, Object> namedParamsCopy = namedParams != null ? new HashMap<>(namedParams) : new HashMap<>()
+ Map<String, Object> namedParamsCopy = namedParams != null ? new HashMap<>(namedParams) : [:]
- List<Object> positionalParamsCopy = positionalParams != null ? new ArrayList<>(positionalParams) : new ArrayList<>()
+ List<Object> positionalParamsCopy = positionalParams != null ? new ArrayList<>(positionalParams) : []
- Map<String, Object> querySettingsCopy = querySettings != null ? new HashMap<>(querySettings) : new HashMap<>()
+ Map<String, Object> querySettingsCopy = querySettings != null ? new HashMap<>(querySettings) : [:]
Map<String, Object> hintsSource = hints != null ? hints : Collections.emptyMap()
Map<String, Object> filteredHints = [:]
for (Map.Entry<String, Object> e : hintsSource.entrySet()) {
- if (AvailableHints.definedHints.contains(e.key)) {
+ if (e.key in AvailableHints.definedHints) {
filteredHints.put(e.key, e.value)
}
}
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/JpaProjectionAdapter.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/JpaProjectionAdapter.groovy
index a3e51acb7a..9c0ae4c513 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/JpaProjectionAdapter.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/JpaProjectionAdapter.groovy
@@ -84,7 +84,7 @@ class JpaProjectionAdapter {
subquery.select((Expression) selections.get(0))
} else if (query instanceof CriteriaQuery) {
CriteriaQuery criteriaQuery = (CriteriaQuery) query
- if (criteriaQuery.resultType.equals(Tuple) && selections.size() > 1) {
+ if (criteriaQuery.resultType == Tuple && selections.size() > 1) {
criteriaQuery.select(criteriaBuilder.tuple(selections.toArray(new Selection<?>[0])))
} else {
criteriaQuery.select((Selection) selections.get(0))
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/JpaQueryContext.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/JpaQueryContext.groovy
index 52adaa2536..16eb5603e3 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/JpaQueryContext.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/JpaQueryContext.groovy
@@ -35,8 +35,8 @@ class JpaQueryContext implements Cloneable {
private final AliasRegistry aliasRegistry
private final JoinTracker joinTracker
private final ExpressionResolver resolver
- private final Map<ParameterExpression<?>, Object> parameterValues = new LinkedHashMap<>()
- private final Map<String, Expression<?>> selectionAliases = new HashMap<>()
+ private final Map<ParameterExpression<?>, Object> parameterValues = [:]
+ private final Map<String, Expression<?>> selectionAliases = [:]
private JpaQueryContext parent
JpaQueryContext() {
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/SqlRestriction.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/SqlRestriction.groovy
index e0f9f53cca..751d4cfe23 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/SqlRestriction.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/SqlRestriction.groovy
@@ -64,7 +64,7 @@ record SqlRestriction(String sql, List<?> values) implements Query.Criterion {
*/
@PackageScope
static List<Integer> placeholderIndexes(String sql) {
- List<Integer> placeholders = new ArrayList<>()
+ List<Integer> placeholders = []
scan(sql, placeholders)
return placeholders
}
@@ -75,7 +75,7 @@ record SqlRestriction(String sql, List<?> values) implements Query.Criterion {
*/
@PackageScope
static boolean endsInLineComment(String sql) {
- return scan(sql, new ArrayList<Integer>())
+ return scan(sql, [])
}
private static boolean scan(String sql, List<Integer> placeholders) {
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/support/ClosureEventListener.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/support/ClosureEventListener.groovy
index 96f0c656e8..cb5fc75dce 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/support/ClosureEventListener.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/support/ClosureEventListener.groovy
@@ -266,7 +266,7 @@ class ClosureEventListener
int index = attributeMapping.getStateArrayPosition()
PersistentProperty property = persistentEntity.getHibernatePropertyByName(p)
- if (property != null && !GormProperties.VERSION.equals(property.getName())) {
+ if (property != null && GormProperties.VERSION != property.name) {
state[index] = reflector.getProperty(entity, property.getName())
}
}
(grails-core) 02/04: wip(groovyism): checkpoint uncommitted idiomatic cleanup before merging H7 stage-2 tip
Posted by bo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
borinquenkid pushed a commit to branch groovyism/hibernate7
in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit 8bf8ac1be0c65d53889aa307cc088e6b915eb0ba
Author: Walter Duque de Estrada <wb...@mac.com>
AuthorDate: Sun Oct 18 18:35:52 2026 -0500
wip(groovyism): checkpoint uncommitted idiomatic cleanup before merging H7 stage-2 tip
Co-Authored-By: Claude Sonnet 5.5 <no...@anthropic.com>
---
.../main/groovy/grails/orm/CriteriaMethods.groovy | 10 +++-------
.../access/TraitPropertyAccessStrategy.groovy | 2 +-
.../column/ColumnConfigToColumnBinder.groovy | 6 ++++--
.../cfg/domainbinding/column/IndexBinder.groovy | 8 ++++----
.../column/StringColumnConstraintsBinder.groovy | 2 +-
.../generator/GrailsIdentityGenerator.groovy | 2 +-
.../generator/GrailsIncrementGenerator.groovy | 2 ++
.../generator/GrailsNativeGenerator.groovy | 14 +++++++-------
.../generator/GrailsSequenceGeneratorEnum.groovy | 8 ++------
.../generator/GrailsSequenceStyleGenerator.groovy | 14 +++++++-------
.../generator/GrailsTableGenerator.groovy | 20 +++++++++++---------
.../hibernate/HibernateAssociation.groovy | 4 ----
.../hibernate/HibernateBasicEnumProperty.groovy | 4 ++--
.../hibernate/HibernateClassMapping.groovy | 2 +-
.../HibernateCompositeIdentityProperty.groovy | 6 +-----
.../hibernate/HibernateMappingBuilder.groovy | 18 ++++++++++--------
.../hibernate/HibernateOneToOneProperty.groovy | 4 ++--
.../hibernate/HibernatePersistentEntity.groovy | 4 ++--
.../hibernate/HibernateToManyEntityProperty.groovy | 2 +-
.../hibernate/HibernateToManyProperty.groovy | 18 +++++++++---------
20 files changed, 71 insertions(+), 79 deletions(-)
diff --git a/grails-data-hibernate7/core/src/main/groovy/grails/orm/CriteriaMethods.groovy b/grails-data-hibernate7/core/src/main/groovy/grails/orm/CriteriaMethods.groovy
index b5cc6e514c..e367ead934 100644
--- a/grails-data-hibernate7/core/src/main/groovy/grails/orm/CriteriaMethods.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/grails/orm/CriteriaMethods.groovy
@@ -66,7 +66,7 @@ enum CriteriaMethods {
SINGLE_RESULT('singleResult'),
CREATE_ALIAS('createAlias')
- private final String name
+ final String name
CriteriaMethods(String name) {
this.name = name
@@ -82,7 +82,7 @@ enum CriteriaMethods {
* @throws groovy.lang.MissingMethodException if the method name is not recognized
*/
static CriteriaMethods fromName(String name, Class<?> targetClass, Object... args) {
- for (CriteriaMethods m : values()) {
+ for (CriteriaMethods m in values()) {
if (m.name == name) {
return m
}
@@ -99,7 +99,7 @@ enum CriteriaMethods {
* @return The corresponding CriteriaMethods enum or null if not found
*/
static CriteriaMethods fromName(String name) {
- for (CriteriaMethods m : values()) {
+ for (CriteriaMethods m in values()) {
if (m.name == name) {
return m
}
@@ -107,8 +107,4 @@ enum CriteriaMethods {
return null
}
- String getName() {
- return name
- }
-
}
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/access/TraitPropertyAccessStrategy.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/access/TraitPropertyAccessStrategy.groovy
index fb0d3ace43..2d0f0b8102 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/access/TraitPropertyAccessStrategy.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/access/TraitPropertyAccessStrategy.groovy
@@ -63,7 +63,7 @@ class TraitPropertyAccessStrategy implements PropertyAccessStrategy {
ReflectionUtils.findMethod(containerJavaType, NameUtils.getGetterName(propertyName, true))
if (booleanReadMethod != null &&
(booleanReadMethod.returnType == Boolean ||
- booleanReadMethod.returnType == boolean.class)) {
+ booleanReadMethod.returnType == boolean)) {
readMethod = booleanReadMethod
}
}
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/column/ColumnConfigToColumnBinder.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/column/ColumnConfigToColumnBinder.groovy
index 40c78c53aa..f8a7c8bed6 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/column/ColumnConfigToColumnBinder.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/column/ColumnConfigToColumnBinder.groovy
@@ -49,10 +49,12 @@ class ColumnConfigToColumnBinder {
column.scale = columnConfig.scale
}
String sqlType = columnConfig.sqlType
- if (sqlType != null && !sqlType.isEmpty()) {
+ if (sqlType) {
column.sqlType = sqlType
}
- if (mappedForm != null && !mappedForm.isUniqueWithinGroup()) {
+ if (mappedForm != null && !mappedForm.uniqueWithinGroup) {
+ // columnConfig.unique is a bare `def` property; its auto-generated getUnique() differs
+ // from isUnique()'s coercion logic (handles non-Boolean values). Keep the explicit call.
column.unique = columnConfig.isUnique()
}
}
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/column/IndexBinder.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/column/IndexBinder.groovy
index db57e6988c..c430b98342 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/column/IndexBinder.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/column/IndexBinder.groovy
@@ -38,15 +38,15 @@ class IndexBinder {
}
String indexDef
if (indexObj instanceof Boolean) {
- if (!((Boolean) indexObj)) {
+ if (!indexObj) {
return
}
- indexDef = "${table.name}_${columnName}_idx".toString()
+ indexDef = "${table.name}_${columnName}_idx"
}
else {
String indexStr = indexObj.toString()
if ('true'.equalsIgnoreCase(indexStr)) {
- indexDef = "${table.name}_${columnName}_idx".toString()
+ indexDef = "${table.name}_${columnName}_idx"
}
else if ('false'.equalsIgnoreCase(indexStr)) {
return
@@ -56,7 +56,7 @@ class IndexBinder {
}
}
String[] indices = indexDef.split(',')
- for (String index : indices) {
+ for (String index in indices) {
table.getOrCreateIndex(index.trim()).addColumn(column)
}
}
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/column/StringColumnConstraintsBinder.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/column/StringColumnConstraintsBinder.groovy
index c30ea64c63..a4cba0053c 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/column/StringColumnConstraintsBinder.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/column/StringColumnConstraintsBinder.groovy
@@ -59,7 +59,7 @@ class StringColumnConstraintsBinder {
return Optional.empty()
}
Integer max = null
- for (String value : inList) {
+ for (String value in inList) {
Integer parsed = parseInt(value)
if (parsed != null && (max == null || parsed > max)) {
max = parsed
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/generator/GrailsIdentityGenerator.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/generator/GrailsIdentityGenerator.groovy
index 10cc288101..3462f20d38 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/generator/GrailsIdentityGenerator.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/generator/GrailsIdentityGenerator.groovy
@@ -32,7 +32,7 @@ class GrailsIdentityGenerator extends IdentityGenerator {
GrailsIdentityGenerator(GeneratorCreationContext context, HibernateSimpleIdentity mappedId) {
Properties generatorProps = mappedId?.properties ?: new Properties()
super.configure(context, generatorProps)
- context.property.value.columns.get(0).identity = true
+ context.property.value.columns[0].identity = true
}
}
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/generator/GrailsIncrementGenerator.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/generator/GrailsIncrementGenerator.groovy
index 8382510dfd..6481cd7041 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/generator/GrailsIncrementGenerator.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/generator/GrailsIncrementGenerator.groovy
@@ -63,6 +63,8 @@ class GrailsIncrementGenerator extends IncrementGenerator {
params.putAll(mappedIdProps)
}
+ // Properties.putAt() does not resolve statically under @CompileStatic (falls back to a dynamic
+ // invokeMethodN call); keep the explicit put() so this stays fully statically dispatched.
params.put(TABLES, domainClass.getTableName(namingStrategy))
params.put(COLUMN, resolveColumnName(context, mappedId))
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/generator/GrailsNativeGenerator.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/generator/GrailsNativeGenerator.groovy
index dee30906af..7736cdd324 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/generator/GrailsNativeGenerator.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/generator/GrailsNativeGenerator.groovy
@@ -54,18 +54,18 @@ class GrailsNativeGenerator extends NativeGenerator {
GrailsNativeGenerator(GeneratorCreationContext context, JdbcEnvironment jdbcEnvironment) {
// Picks the delegate for the dialect; for IDENTITY it also calls setIdentity(true) on the column.
- this.initialize(DEFAULT_ANNOTATION, null, context)
- this.configure(context, new Properties())
+ initialize(DEFAULT_ANNOTATION, null, context)
+ configure(context, new Properties())
Database database = context.database
- this.registerExportables(database)
+ registerExportables(database)
def physicalName = database.defaultNamespace.physicalName
- String catalog = physicalName.catalog() != null ? physicalName.catalog().canonicalName : null
- String schema = physicalName.schema() != null ? physicalName.schema().canonicalName : null
+ String catalog = physicalName.catalog()?.canonicalName
+ String schema = physicalName.schema()?.canonicalName
SqlStringGenerationContext sqlContext =
SqlStringGenerationContextImpl.fromExplicit(jdbcEnvironment, database, catalog, schema)
- this.initialize(sqlContext)
+ initialize(sqlContext)
}
@Override
@@ -79,7 +79,7 @@ class GrailsNativeGenerator extends NativeGenerator {
// 2. Fix the Hibernate 7 ClassCastException
// NativeGenerator.generate() tries to cast the delegate to BeforeExecutionGenerator.
// If the dialect chose IDENTITY, that cast fails. We bypass it by returning null.
- if (this.generationType == GenerationType.IDENTITY) {
+ if (generationType == GenerationType.IDENTITY) {
return null
}
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/generator/GrailsSequenceGeneratorEnum.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/generator/GrailsSequenceGeneratorEnum.groovy
index abadab9d78..ae03bbcd32 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/generator/GrailsSequenceGeneratorEnum.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/generator/GrailsSequenceGeneratorEnum.groovy
@@ -49,16 +49,12 @@ enum GrailsSequenceGeneratorEnum {
HILO('hilo'),
NATIVE('native')
- private final String name
+ final String name
GrailsSequenceGeneratorEnum(String name) {
this.name = name
}
- String getName() {
- return name
- }
-
@Override
String toString() {
return name
@@ -93,7 +89,7 @@ enum GrailsSequenceGeneratorEnum {
case INCREMENT:
return new GrailsIncrementGenerator(context, mappedId, domainClass, namingStrategy)
case [UUID, UUID2]:
- return new UuidGenerator(context.getType().getReturnedClass())
+ return new UuidGenerator(context.type.returnedClass)
case ASSIGNED:
return new Assigned()
case [TABLE, ENHANCED_TABLE]:
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/generator/GrailsSequenceStyleGenerator.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/generator/GrailsSequenceStyleGenerator.groovy
index 4a5ce16eff..72a255a965 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/generator/GrailsSequenceStyleGenerator.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/generator/GrailsSequenceStyleGenerator.groovy
@@ -51,23 +51,23 @@ class GrailsSequenceStyleGenerator extends SequenceStyleGenerator {
generatorProps.putIfAbsent(PersistentIdentifierGenerator.TABLE, context.rootClass.table.name)
}
- this.configure(context, generatorProps)
+ configure(context, generatorProps)
if (jdbcEnvironment != null) {
def database = context.database
if (databaseStructure != null) {
- this.registerExportables(database)
+ registerExportables(database)
}
def physicalName = database.defaultNamespace.physicalName
- String catalog = physicalName.catalog() != null ? physicalName.catalog().canonicalName : null
- String schema = physicalName.schema() != null ? physicalName.schema().canonicalName : null
+ String catalog = physicalName.catalog()?.canonicalName
+ String schema = physicalName.schema()?.canonicalName
if (databaseStructure != null) {
SqlStringGenerationContext sqlContext =
SqlStringGenerationContextImpl.fromExplicit(jdbcEnvironment, database, catalog, schema)
- this.initialize(sqlContext)
+ initialize(sqlContext)
}
}
}
@@ -78,9 +78,9 @@ class GrailsSequenceStyleGenerator extends SequenceStyleGenerator {
* at all. Anything the generator would treat as unnamed still needs the target table to derive one.
*/
private static boolean hasExplicitSequenceName(Properties generatorProps) {
- Object sequenceName = generatorProps.get(SEQUENCE_PARAM)
+ Object sequenceName = generatorProps[SEQUENCE_PARAM]
if (sequenceName == null) {
- sequenceName = generatorProps.get(ALT_SEQUENCE_PARAM)
+ sequenceName = generatorProps[ALT_SEQUENCE_PARAM]
}
return sequenceName != null && !sequenceName.toString().isEmpty()
}
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/generator/GrailsTableGenerator.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/generator/GrailsTableGenerator.groovy
index c7f0658d49..69fe56dafb 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/generator/GrailsTableGenerator.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/generator/GrailsTableGenerator.groovy
@@ -37,41 +37,43 @@ class GrailsTableGenerator extends TableGenerator {
GrailsTableGenerator(GeneratorCreationContext context, HibernateSimpleIdentity mappedId, JdbcEnvironment jdbcEnvironment) {
Properties generatorProps = mappedId?.properties ?: new Properties()
- if (!generatorProps.containsKey(SEGMENT_VALUE_PARAM)) {
+ if (!(SEGMENT_VALUE_PARAM in generatorProps)) {
String propertyName = context.property.name
// Use the name we just ensured exists in BasicValueCreator
- String entityName = (mappedId != null && mappedId.name != null) ? mappedId.name : DEFAULT_ENTITY_NAME
+ String entityName = mappedId?.name != null ? mappedId.name : DEFAULT_ENTITY_NAME
+ // Properties.putAt() does not resolve statically under @CompileStatic (falls back to a
+ // dynamic invokeMethodN call); keep the explicit put() so this stays fully statically dispatched.
generatorProps.put(SEGMENT_VALUE_PARAM, entityName + '.' + propertyName)
}
// Standard Pooled-lo defaults
- if (!generatorProps.containsKey(INCREMENT_PARAM)) {
+ if (!(INCREMENT_PARAM in generatorProps)) {
generatorProps.put(INCREMENT_PARAM, '50')
}
- if (!generatorProps.containsKey(OPT_PARAM)) {
+ if (!(OPT_PARAM in generatorProps)) {
generatorProps.put(OPT_PARAM, 'pooled-lo')
}
// Fixes the "SQL to format should not be null" error
- this.configure(context, generatorProps)
+ configure(context, generatorProps)
def database = context.database
- this.registerExportables(database)
+ registerExportables(database)
// Get the Name record from the physical name
def physicalName = database.defaultNamespace.physicalName
// Use the record component accessors (catalog() and schema())
// instead of the deprecated getCatalog()/getSchema()
- String catalog = physicalName.catalog() != null ? physicalName.catalog().canonicalName : null
+ String catalog = physicalName.catalog()?.canonicalName
- String schema = physicalName.schema() != null ? physicalName.schema().canonicalName : null
+ String schema = physicalName.schema()?.canonicalName
// Build the context and initialize templates
SqlStringGenerationContext context1 =
SqlStringGenerationContextImpl.fromExplicit(jdbcEnvironment, database, catalog, schema)
- this.initialize(context1)
+ initialize(context1)
}
}
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateAssociation.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateAssociation.groovy
index 809f9663a4..d4fe79e92d 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateAssociation.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateAssociation.groovy
@@ -41,8 +41,6 @@ import org.grails.orm.hibernate.cfg.PropertyConfig
@CompileStatic
interface HibernateAssociation extends HibernatePersistentProperty {
- // --- Association contract (satisfied by the class hierarchy of all implementors) ---
-
PersistentProperty<?> getInverseSide()
PersistentEntity getAssociatedEntity()
@@ -63,8 +61,6 @@ interface HibernateAssociation extends HibernatePersistentProperty {
return true
}
- // --- Hibernate-typed overrides, removing instanceof guards ---
-
/** Returns the inverse side as a {@link HibernateAssociation}, eliminating cast at call sites. */
@Override
default HibernateAssociation getHibernateInverseSide() {
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateBasicEnumProperty.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateBasicEnumProperty.groovy
index 820665faea..7bad1eee55 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateBasicEnumProperty.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateBasicEnumProperty.groovy
@@ -75,8 +75,8 @@ class HibernateBasicEnumProperty extends HibernateBasicProperty implements Hiber
@Override
Table getTable() {
Collection collection = hibernateCollection
- Table collectionTable = collection != null ? collection.collectionTable : null
- return collectionTable != null ? collectionTable : persistentClass.table
+ Table collectionTable = collection?.collectionTable
+ return collectionTable ?: persistentClass.table
}
}
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateClassMapping.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateClassMapping.groovy
index b1f3bd47c4..9ba1623202 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateClassMapping.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateClassMapping.groovy
@@ -40,7 +40,7 @@ class HibernateClassMapping extends AbstractClassMapping<Mapping> {
HibernateClassMapping(PersistentEntity entity, MappingContext context) {
super(entity, context)
this.mappedForm = (Mapping) context.mappingFactory.createMappedForm(entity)
- for (PropertyConfig propConf : mappedForm.propertyConfigs.values()) {
+ for (PropertyConfig propConf in mappedForm.propertyConfigs.values()) {
if (propConf != null && propConf.cascade != null) {
propConf.explicitSaveUpdateCascade = CascadeBehavior.isSaveUpdate(propConf.cascade)
}
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateCompositeIdentityProperty.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateCompositeIdentityProperty.groovy
index fee91ad02b..eb192ef731 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateCompositeIdentityProperty.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateCompositeIdentityProperty.groovy
@@ -28,7 +28,7 @@ import java.beans.PropertyDescriptor
@CompileStatic
class HibernateCompositeIdentityProperty extends HibernateIdentityProperty {
- private final HibernatePersistentProperty[] parts
+ final HibernatePersistentProperty[] parts
HibernateCompositeIdentityProperty(PersistentEntity entity, MappingContext context, PropertyDescriptor property) {
super(entity, context, property)
@@ -46,8 +46,4 @@ class HibernateCompositeIdentityProperty extends HibernateIdentityProperty {
this.parts = parts != null ? parts : new HibernatePersistentProperty[0]
}
- HibernatePersistentProperty[] getParts() {
- return parts
- }
-
}
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateMappingBuilder.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateMappingBuilder.groovy
index c33ffd4918..ee3d35fc1d 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateMappingBuilder.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateMappingBuilder.groovy
@@ -302,13 +302,13 @@ class HibernateMappingBuilder implements MappingConfigurationBuilder<Mapping, Pr
*/
protected void handlePropertyInternal(String name, Map<String, Object> namedArgs, Closure subClosure) {
PropertyConfig newConfig = new PropertyConfig()
- if (defaultConstraints != null && namedArgs.containsKey('shared')) {
- PropertyConfig sharedConstraints = mapping.columns.get(namedArgs.shared.toString())
+ if (defaultConstraints != null && 'shared' in namedArgs) {
+ PropertyConfig sharedConstraints = mapping.columns[namedArgs.shared.toString()]
if (sharedConstraints != null) {
newConfig = (PropertyConfig) sharedConstraints.clone()
}
- } else if (mapping.columns.containsKey('*')) {
- PropertyConfig globalConstraints = mapping.columns.get('*')
+ } else if ('*' in mapping.columns) {
+ PropertyConfig globalConstraints = mapping.columns['*']
if (globalConstraints != null) {
newConfig = (PropertyConfig) globalConstraints.clone()
}
@@ -343,6 +343,8 @@ class HibernateMappingBuilder implements MappingConfigurationBuilder<Mapping, Pr
if (namedArgs.ignoreNotFound instanceof Boolean) property.ignoreNotFound = (Boolean) namedArgs.ignoreNotFound
if (namedArgs.params instanceof Map) {
Properties typeProps = new Properties()
+ // Properties.putAt() does not resolve statically under @CompileStatic (falls back to a
+ // dynamic invokeMethodN call); keep the explicit put() so this stays fully statically dispatched.
((Map<Object, Object>) namedArgs.params).each { Object k, Object v -> typeProps.put(k, v) }
property.typeParams = typeProps
}
@@ -471,8 +473,8 @@ class HibernateMappingBuilder implements MappingConfigurationBuilder<Mapping, Pr
}
void methodMissing(String name, Object args) {
- if (methodMissingIncludes != null && !methodMissingIncludes.contains(name)) return
- if (methodMissingExcludes.contains(name)) return
+ if (methodMissingIncludes != null && !(name in methodMissingIncludes)) return
+ if (name in methodMissingExcludes) return
Object[] argsArray = (Object[]) args
int argc = argsArray.length
@@ -492,8 +494,8 @@ class HibernateMappingBuilder implements MappingConfigurationBuilder<Mapping, Pr
try {
if (lastArg instanceof Map) {
Map<String, Object> argMap = (Map<String, Object>) lastArg
- Object includes = argMap.get(INCLUDE_PARAM)
- Object excludes = argMap.get(EXCLUDE_PARAM)
+ Object includes = argMap[INCLUDE_PARAM]
+ Object excludes = argMap[EXCLUDE_PARAM]
if (includes instanceof List) methodMissingIncludes = (List<String>) includes
if (excludes instanceof List) methodMissingExcludes = (List<String>) excludes
}
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateOneToOneProperty.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateOneToOneProperty.groovy
index eaf970d28f..728c83874c 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateOneToOneProperty.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateOneToOneProperty.groovy
@@ -80,7 +80,7 @@ class HibernateOneToOneProperty extends OneToOneWithMapping<PropertyConfig> impl
*/
String getHibernateReferencedPropertyName() {
HibernateOneToOneProperty otherSide = hibernateInverseSide
- return otherSide != null ? otherSide.name : null
+ return otherSide?.name
}
/** FK direction: FROM_PARENT when constrained (hasOne on other side), TO_PARENT otherwise. */
@@ -91,7 +91,7 @@ class HibernateOneToOneProperty extends OneToOneWithMapping<PropertyConfig> impl
/** Resolved fetch mode: uses the configured value or falls back to {@link FetchMode#DEFAULT}. */
FetchMode getHibernateFetchMode() {
PropertyConfig config = hibernateMappedForm
- return (config != null && config.fetchMode != null) ? config.fetchMode : FetchMode.DEFAULT
+ return config?.fetchMode ?: FetchMode.DEFAULT
}
/**
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernatePersistentEntity.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernatePersistentEntity.groovy
index 3592391417..492de6d359 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernatePersistentEntity.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernatePersistentEntity.groovy
@@ -112,7 +112,7 @@ class HibernatePersistentEntity extends AbstractPersistentEntity<Mapping> implem
@Override
boolean forGrailsDomainMapping(String dataSourceName) {
- return !isAnnotatedEntity() && usesConnectionSource(dataSourceName) && isRoot()
+ return !annotatedEntity && usesConnectionSource(dataSourceName) && root
}
@Override
@@ -138,7 +138,7 @@ class HibernatePersistentEntity extends AbstractPersistentEntity<Mapping> implem
if (hibernateIdentity instanceof HibernateSimpleIdentity) {
HibernateSimpleIdentity simpleIdentity = (HibernateSimpleIdentity) hibernateIdentity
Mapping result = hibernateMappedForm
- boolean useSequence = result != null && result.isTablePerConcreteClass()
+ boolean useSequence = result?.isTablePerConcreteClass() ?: false
return simpleIdentity.determineGeneratorName(useSequence)
}
throw new MappingException('Simple Identity expected')
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateToManyEntityProperty.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateToManyEntityProperty.groovy
index 2da567cd06..737a23cb07 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateToManyEntityProperty.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateToManyEntityProperty.groovy
@@ -32,7 +32,7 @@ interface HibernateToManyEntityProperty extends HibernateToManyProperty {
HibernatePersistentEntity getHibernateAssociatedEntity()
default PersistentClass getAssociatedClass() {
- PersistentClass associatedClass = getHibernateAssociatedEntity().persistentClass
+ PersistentClass associatedClass = hibernateAssociatedEntity.persistentClass
if (associatedClass == null) {
throw new MappingException("Association [${name}] has no associated class")
}
diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateToManyProperty.groovy b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateToManyProperty.groovy
index 4c83774133..ca62323c18 100644
--- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateToManyProperty.groovy
+++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernateToManyProperty.groovy
@@ -94,7 +94,7 @@ interface HibernateToManyProperty extends PropertyWithMapping<PropertyConfig>, H
PropertyConfig mapped = hibernateMappedForm
CacheConfig cache = mapped?.cache
Object usage = cache?.usage
- return usage != null ? usage.toString() : null
+ return usage?.toString()
}
default boolean isBasic() {
@@ -172,7 +172,7 @@ interface HibernateToManyProperty extends PropertyWithMapping<PropertyConfig>, H
if (mapped != null && mapped.indexColumn != null) {
PropertyConfig indexColConfig = mapped.indexColumn
if (!indexColConfig.columns.isEmpty()) {
- String name = indexColConfig.columns.get(0).name
+ String name = indexColConfig.columns[0].name
if (StringUtils.hasText(name)) {
return name
}
@@ -185,12 +185,12 @@ interface HibernateToManyProperty extends PropertyWithMapping<PropertyConfig>, H
IndexedCollection.DEFAULT_INDEX_COLUMN_NAME
}
- ColumnConfig primaryCol = mapped.columns.get(0)
+ ColumnConfig primaryCol = mapped.columns[0]
Object rawIndex = primaryCol.index
if (rawIndex instanceof groovy.lang.Closure) {
PropertyConfig indexColConfig = PropertyConfig.configureNew((groovy.lang.Closure<?>) rawIndex)
if (!indexColConfig.columns.isEmpty()) {
- String name = indexColConfig.columns.get(0).name
+ String name = indexColConfig.columns[0].name
if (StringUtils.hasText(name)) {
return name
}
@@ -199,7 +199,7 @@ interface HibernateToManyProperty extends PropertyWithMapping<PropertyConfig>, H
try {
Map<String, String> indexMap = primaryCol.indexAsMap
- String colName = indexMap.get('column')
+ String colName = indexMap['column']
if (StringUtils.hasText(colName)) {
return colName
@@ -226,7 +226,7 @@ interface HibernateToManyProperty extends PropertyWithMapping<PropertyConfig>, H
return defaultType
}
- ColumnConfig primaryCol = mapped.columns.get(0)
+ ColumnConfig primaryCol = mapped.columns[0]
Object rawIndex = primaryCol.index
if (rawIndex instanceof groovy.lang.Closure) {
PropertyConfig indexColConfig = PropertyConfig.configureNew((groovy.lang.Closure<?>) rawIndex)
@@ -237,7 +237,7 @@ interface HibernateToManyProperty extends PropertyWithMapping<PropertyConfig>, H
try {
Map<String, String> indexMap = primaryCol.indexAsMap
- String typeName = indexMap.get('type')
+ String typeName = indexMap['type']
if (StringUtils.hasText(typeName)) {
return typeName
@@ -312,13 +312,13 @@ interface HibernateToManyProperty extends PropertyWithMapping<PropertyConfig>, H
@NonNull
default Optional<ColumnConfig> getColumnConfigOptional() {
PropertyConfig mapped = hibernateMappedForm
- return Optional.ofNullable(mapped != null ? mapped.joinTableColumnConfig : null)
+ return Optional.ofNullable(mapped?.joinTableColumnConfig)
}
@Override
default boolean isEnum() {
Class<?> compType = componentType
- return compType != null && compType.isEnum()
+ return compType?.isEnum() ?: false
}
/**
(grails-core) 03/04: Merge refactor/java-to-groovy-grails-data-hibernate7 into groovyism/hibernate7
Posted by bo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
borinquenkid pushed a commit to branch groovyism/hibernate7
in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit dd40513f715e52c3299ae2fe8fcf238daeac836c
Merge: 8bf8ac1be0 4f2cdef51e
Author: Walter Duque de Estrada <wb...@mac.com>
AuthorDate: Sun Oct 18 18:43:19 2026 -0500
Merge refactor/java-to-groovy-grails-data-hibernate7 into groovyism/hibernate7
Style-only stage-2 conflicts keep the idiomatic side; the classic domain binder
stays deleted; upgrading90x.adoc keeps both sections.
Co-Authored-By: Claude Sonnet 5.5 <no...@anthropic.com>
.agents/skills/gradle-developer/SKILL.md | 8 +
.github/workflows/gradle.yml | 2 +-
AGENTS.md | 1 +
.../apache/grails/buildsrc/CompilePlugin.groovy | 56 +-
.../grails/buildsrc/CompilePluginSpec.groovy | 58 ++
dependencies.gradle | 2 +-
gradle/grails-extension-gradle-config.gradle | 4 +-
.../org/grails/io/support/AntPathMatcher.java | 36 +-
.../grails/io/support/AntPathMatcherSpec.groovy | 347 ++++++++++
.../grails/io/support/ByteArrayResourceSpec.groovy | 97 +++
grails-common/build.gradle | 4 -
grails-converters/build.gradle | 3 +-
.../src/main/groovy/grails/converters/JSON.java | 75 ++-
.../converters/ConvertersGrailsPlugin.groovy | 20 +
.../ConvertersConfigurationHolder.java | 44 ++
.../ConvertersConfigurationInitializer.java | 161 ++++-
.../jackson/DomainClassJacksonModule.java | 119 ++++
.../converters/jackson/DomainClassRendering.java | 256 ++++++++
.../converters/jackson/DomainClassSerializer.java | 481 ++++++++++++++
.../marshaller/json/ByteArrayMarshaller.java | 4 +
.../marshaller/json/CalendarMarshaller.java | 4 +
.../converters/marshaller/json/DateMarshaller.java | 4 +
.../marshaller/json/DomainClassMarshaller.java | 104 ++-
.../marshaller/json/InstantMarshaller.java | 4 +
.../marshaller/json/JsonMapperValueMarshaller.java | 88 +++
.../marshaller/json/LocalDateMarshaller.java | 4 +
.../marshaller/json/LocalDateTimeMarshaller.java | 4 +
.../converters/marshaller/json/MapMarshaller.java | 3 +-
.../marshaller/json/OffsetDateTimeMarshaller.java | 4 +
...rrayMarshaller.java => OptionalMarshaller.java} | 15 +-
...alDateMarshaller.java => RecordMarshaller.java} | 30 +-
.../marshaller/json/SimpleEnumMarshaller.java | 17 +-
.../marshaller/json/ToStringBeanMarshaller.java | 4 +
.../marshaller/json/ZonedDateTimeMarshaller.java | 4 +
.../converters/ConvertersGrailsPluginSpec.groovy | 104 +++
.../ConvertersConfigurationInitializerSpec.groovy | 77 +++
.../jackson/DomainClassJacksonModuleSpec.groovy | 524 +++++++++++++++
.../converters/json/JsonMapperRenderingSpec.groovy | 719 ++++++++++++++++++++
.../web/converters/json/JsonParsingSpec.groovy | 99 +++
.../json/legacy/Grails8DomainRendering.groovy | 213 ++++++
.../json/legacy/Grails8JsonRenderingSpec.groovy | 397 +++++++++++
.../commands/io/FileSystemInteractionImpl.groovy | 9 +-
.../io/FileSystemInteractionImplSpec.groovy | 75 +++
.../core/cli/io/FileSystemInteractionImpl.groovy | 9 +-
.../groovy/org/grails/config/CompositeConfig.java | 59 +-
.../additional-spring-configuration-metadata.json | 12 +
.../cli/io/FileSystemInteractionImplSpec.groovy | 75 +++
.../beans/util/LazyMetaPropertyMapSpec.groovy | 138 ++++
.../groovy/grails/util/GrailsClassUtilsSpec.groovy | 192 ++++++
.../org/grails/config/CompositeConfigSpec.groovy | 220 +++++++
.../org/grails/config/PrefixedConfigSpec.groovy | 141 ++++
.../org/grails/core/util/StopWatchSpec.groovy | 150 +++++
grails-data-hibernate5/core/build.gradle | 4 +
.../proxy/ByteBuddyGroovyInterceptor.java | 23 +
.../proxy/ByteBuddyGroovyProxyFactory.java | 30 +-
.../hibernate/proxy/GroovyProxyClassBuilder.java | 115 ++++
.../proxy/GroovyProxyMetaClassDispatcher.java | 57 ++
.../hibernate/proxy/SerializableGroovyProxy.java | 126 ++++
.../TraitInitializerProxySpec.groovy | 232 +++++++
.../proxy/ByteBuddyGroovyProxyFactorySpec.groovy | 175 +++++
.../proxy/GroovyProxyClassBuilderSpec.groovy | 109 ++++
.../GroovyProxyMetaClassDispatcherSpec.groovy | 47 ++
.../proxy/SerializableGroovyProxySpec.groovy | 111 ++++
grails-data-hibernate7/core/build.gradle | 2 +
.../HibernateEmbeddedPersistentEntity.groovy | 58 +-
.../hibernate/HibernateOneToManyProperty.groovy | 46 +-
.../util/NamespaceNameExtractor.groovy | 40 +-
.../domainbinding/util/UniqueNameGenerator.groovy | 55 +-
.../proxy/ByteBuddyGroovyInterceptor.groovy | 27 +-
.../proxy/ByteBuddyGroovyProxyFactory.groovy | 121 ++--
.../hibernate/proxy/GrailsBytecodeProvider.groovy | 48 +-
.../proxy/GrailsProxyFactoryFactory.groovy | 2 +-
.../hibernate/proxy/GroovyProxyClassBuilder.groovy | 101 +++
.../proxy/GroovyProxyInterceptorLogic.groovy | 79 +--
.../proxy/GroovyProxyMetaClassDispatcher.groovy | 61 ++
.../hibernate/proxy/HibernateProxyHandler.groovy | 108 +--
.../hibernate/proxy/SerializableGroovyProxy.groovy | 148 +++++
.../orm/hibernate/query/AliasRegistry.groovy | 43 +-
.../query/GrailsSqlRestrictionFunction.groovy | 87 +--
.../query/HibernatePagedResultList.groovy | 119 ++--
.../grails/orm/hibernate/query/JoinTracker.groovy | 35 +-
.../hibernate/query/JpaCriteriaQueryCreator.groovy | 285 ++++----
.../hibernate/query/JpaProjectionTranslator.groovy | 148 ++---
.../orm/hibernate/query/MutationHqlQuery.groovy | 54 +-
.../orm/hibernate/query/RegexDialectPattern.groovy | 45 +-
.../orm/hibernate/query/SelectHqlQuery.groovy | 85 +--
.../orm/hibernate/query/SelectQueryDelegate.groovy | 55 +-
.../TraitInitializerProxySpec.groovy | 232 +++++++
.../proxy/ByteBuddyGroovyInterceptorSpec.groovy | 28 +
.../proxy/ByteBuddyGroovyProxyFactorySpec.groovy | 152 ++++-
.../proxy/GrailsBytecodeProviderSpec.groovy | 47 ++
.../proxy/GroovyProxyClassBuilderSpec.groovy | 107 +++
.../GroovyProxyMetaClassDispatcherSpec.groovy | 47 ++
.../proxy/SerializableGroovyProxySpec.groovy | 112 ++++
.../dbmigration-core/build.gradle | 2 +
.../database/HibernateClassicDatabase.groovy | 77 +--
.../database/HibernateEjb3Database.groovy | 129 ++--
.../database/HibernateGenericDialect.groovy | 13 +-
.../database/HibernateSpringBeanDatabase.groovy | 167 ++---
.../database/HibernateSpringPackageDatabase.groovy | 163 ++---
.../database/JpaPersistenceDatabase.groovy | 53 +-
.../database/NoOpConnectionProvider.groovy | 29 +-
.../NoOpMultiTenantConnectionProvider.groovy | 29 +-
.../database/connection/HibernateConnection.groovy | 173 ++---
.../connection/HibernateConnectionMetadata.groovy | 725 +++++++++++----------
.../database/connection/HibernateDriver.groovy | 39 +-
.../HibernateChangedColumnChangeGenerator.groovy | 73 ++-
...ibernateChangedForeignKeyChangeGenerator.groovy | 39 +-
.../HibernateChangedIndexChangeGenerator.groovy | 39 +-
...ibernateChangedPrimaryKeyChangeGenerator.groovy | 39 +-
.../HibernateMissingSequenceChangeGenerator.groovy | 33 +-
.../HibernateUnexpectedIndexChangeGenerator.groovy | 31 +-
.../HibernateCatalogSnapshotGenerator.groovy | 31 +-
.../HibernateForeignKeySnapshotGenerator.groovy | 69 +-
.../HibernateIndexSnapshotGenerator.groovy | 95 +--
.../HibernatePrimaryKeySnapshotGenerator.groovy | 87 +--
.../HibernateSchemaSnapshotGenerator.groovy | 33 +-
.../HibernateSequenceSnapshotGenerator.groovy | 109 ++--
.../snapshot/HibernateSnapshotGenerator.groovy | 101 +--
.../HibernateTableSnapshotGenerator.groovy | 81 +--
...bernateUniqueConstraintSnapshotGenerator.groovy | 153 ++---
.../snapshot/HibernateViewSnapshotGenerator.groovy | 29 +-
.../snapshot/IdentifierGeneratorSupport.groovy | 61 +-
.../extension/ExtendedSnapshotGenerator.groovy | 11 +-
.../TableGeneratorSnapshotGenerator.groovy | 85 +--
.../hibernate/ColumnRemarksIntegrationTest.groovy | 106 +--
.../database/HibernateClassicDatabaseTest.groovy | 128 ++--
.../database/HibernateDatabaseTest.groovy | 12 +-
.../database/HibernateEjb3DatabaseTest.groovy | 146 ++---
.../database/HibernateSpringDatabaseTest.groovy | 144 ++--
.../database/JPAPersistenceDatabaseTest.groovy | 32 +-
.../connection/HibernateConnectionTest.groovy | 58 +-
.../HibernateIndexDifferenceSuppressionTest.groovy | 114 ++--
.../snapshot/CustomIdGeneratorTest.groovy | 58 +-
.../HibernateColumnSnapshotGeneratorTest.groovy | 168 ++---
.../IdentifierGeneratorSnapshotTest.groovy | 110 ++--
.../NativeGeneratorAutoIncrementTest.groovy | 58 +-
.../snapshot/NativeGeneratorSequenceTest.groovy | 56 +-
.../snapshot/SequenceGeneratorTest.groovy | 56 +-
.../groovy/liquibase/harness/diff/Authors.groovy | 84 +--
.../groovy/liquibase/harness/diff/Posts.groovy | 82 +--
.../groovy/com/example/columnremarks/Item.groovy | 24 +-
.../com/example/customconfig/auction/Item.groovy | 18 +-
.../com/example/ejb3/auction/AuctionInfo.groovy | 26 +-
.../com/example/ejb3/auction/AuctionItem.groovy | 34 +-
.../com/example/ejb3/auction/AuditedItem.groovy | 26 +-
.../groovy/com/example/ejb3/auction/Bid.groovy | 38 +-
.../groovy/com/example/ejb3/auction/BuyNow.groovy | 12 +-
.../com/example/ejb3/auction/FirstTable.groovy | 26 +-
.../groovy/com/example/ejb3/auction/Item.groovy | 24 +-
.../groovy/com/example/ejb3/auction/Name.groovy | 28 +-
.../com/example/ejb3/auction/Persistent.groovy | 12 +-
.../com/example/ejb3/auction/SecondTable.groovy | 12 +-
.../groovy/com/example/ejb3/auction/User.groovy | 28 +-
.../groovy/com/example/ejb3/auction/Watcher.groovy | 28 +-
.../example/ejb3/customid/CustomIdEntity.groovy | 20 +-
.../example/ejb3/customid/NativeGenEntity.groovy | 28 +-
.../com/example/ejb3/customid/SnowflakeId.groovy | 18 +-
.../ejb3/customid/SnowflakeIdGenerator.groovy | 14 +-
.../com/example/pojo/auction/AuctionInfo.groovy | 20 +-
.../com/example/pojo/auction/AuctionItem.groovy | 20 +-
.../groovy/com/example/pojo/auction/Bid.groovy | 16 +-
.../groovy/com/example/pojo/auction/BuyNow.groovy | 8 +-
.../groovy/com/example/pojo/auction/Name.groovy | 26 +-
.../com/example/pojo/auction/Persistent.groovy | 6 +-
.../groovy/com/example/pojo/auction/User.groovy | 18 +-
.../groovy/com/example/pojo/auction/Watcher.groovy | 18 +-
grails-data-hibernate7/dbmigration/build.gradle | 2 +
.../HibernatePersistenceContextInterceptor.groovy | 201 +++---
.../support/AsyncRequestInterceptor.groovy | 87 +--
grails-data-mongodb/core/build.gradle | 2 +
.../Jsr310ConvertersConfiguration.groovy | 6 +-
.../en/guide/REST/renderers/defaultRenderers.adoc | 108 ++-
.../src/en/guide/deployment/deploymentAot.adoc | 6 +
grails-doc/src/en/guide/introduction/whatsNew.adoc | 31 +
.../springSecurity/core/filters.adoc | 2 +
.../src/en/guide/upgrading/upgrading80x.adoc | 79 ++-
.../src/en/guide/upgrading/upgrading90x.adoc | 273 +++++++-
.../gradle/classic-framework.init.gradle | 30 +-
grails-forge/gradle/test-config.gradle | 10 +
grails-forge/grails-forge-cli/build.gradle | 4 -
.../groovy/org/grails/forge/cli/CommandSpec.groovy | 16 +-
.../org/grails/forge/cli/GeneratedBuildSpec.groovy | 32 +-
.../forge/cli/command/CreateAppCommandSpec.groovy | 21 +
.../org/grails/forge/cli/GeneratedBuild.groovy | 48 ++
.../feature/database/GrailsDataHibernate5.groovy | 7 +-
.../feature/database/GrailsDataHibernate7.groovy | 7 +-
.../database/GrailsDataHibernate5Spec.groovy | 12 +-
.../database/GrailsDataHibernate7Spec.groovy | 10 +-
.../org/grails/forge/utils/CommandSpec.groovy | 7 +-
.../org/grails/io/support/GrailsResourceUtils.java | 4 +-
.../grails/io/support/ClassPathResourceSpec.groovy | 141 ++++
.../io/support/FileSystemResourceSpec.groovy | 137 ++++
.../io/support/GrailsResourceUtilsSpec.groovy | 262 ++++++++
.../grails/io/support/MainClassFinderSpec.groovy | 171 ++++-
.../org/grails/io/support/UrlResourceSpec.groovy | 136 ++++
.../gradle/plugin/core/GrailsExtension.groovy | 12 +-
.../gradle/plugin/core/GrailsGradlePlugin.groovy | 61 +-
.../gradle/plugin/core/GrailsExtensionSpec.groovy | 23 +
.../gradle/plugin/core/GrailsIndySpec.groovy | 75 +++
.../core/GrailsNativeImageDefaultsSpec.groovy | 53 +-
.../test-projects/indy-settings/build.gradle | 40 ++
.../test-projects/indy-settings/gradle.properties | 1 +
.../indy-settings/grails-app/conf/application.yml | 0
.../test-projects/indy-settings/settings.gradle | 1 +
.../src/main/groovy/demo/Dynamic.groovy | 5 +
.../test-projects/native-defaults-off/build.gradle | 7 +-
.../test-projects/native-defaults-on/build.gradle | 47 +-
.../src/main/groovy/demo/Dynamic.groovy | 5 +
.../web/layout/TokenizedHTMLPage2Content.java | 2 +-
.../web/layout/GSPGrailsLayoutPageSpec.groovy | 155 +++++
.../web/layout/GrailsHTMLPageParserSpec.groovy | 82 +++
.../web/layout/GrailsLayoutTagLibSpec.groovy | 112 ++++
.../layout/GrailsPageResponseWrapperSpec.groovy | 223 +++++++
.../layout/GrailsViewBufferingResponseSpec.groovy | 165 +++++
.../grails/web/layout/LayoutDecoratorSpec.groovy | 125 ++++
.../web/layout/RenderGrailsLayoutTagLibSpec.groovy | 102 +++
.../web/rest/render/atom/AtomRendererSpec.groovy | 261 ++++++++
.../web/rest/render/hal/HalXmlRendererSpec.groovy | 290 +++++++++
grails-shell-cli/build.gradle | 2 +
.../commands/io/FileSystemInteractionImpl.groovy | 9 +-
.../grails/cli/command/CommandExceptionSpec.groovy | 73 +++
.../grails/cli/command/CommandRunnerSpec.groovy | 269 ++++++++
.../org/grails/cli/command/HelpExampleSpec.groovy | 31 +-
.../cli/command/OptionParsingCommandSpec.groovy | 84 +++
.../io/FileSystemInteractionImplSpec.groovy | 151 +++++
.../templates/TemplateRendererImplSpec.groovy | 151 +++++
.../developer/skills/grails-developer/SKILL.md | 30 +
.../intercept/FilterSecurityInterceptor.groovy | 4 +
.../intercept/FilterSecurityInterceptorSpec.groovy | 141 +++-
.../grails-hibernate-groovy-proxy/build.gradle | 1 +
.../grails-app/conf/application.yml | 4 +
.../grails-app/domain/example/Book.groovy} | 25 +-
.../grails-app/domain/example/Loan.groovy} | 26 +-
.../example/TraitDefaultValuesProxySpec.groovy | 189 ++++++
.../src/main/groovy/example/Auditable.groovy} | 26 +-
.../hibernate5/grails-hibernate/build.gradle | 1 +
.../grails-app/conf/application.yml | 11 +-
.../functional/tests/ShipmentController.groovy} | 20 +-
.../domain/functional/tests/Carrier.groovy} | 18 +-
.../domain/functional/tests/Shipment.groovy} | 19 +-
.../tests/JsonMapperConverterSpec.groovy | 86 +++
.../grails-hibernate-groovy-proxy/build.gradle | 1 +
.../grails-app/conf/application.yml | 5 +-
.../grails-app/domain/example/Book.groovy} | 25 +-
.../grails-app/domain/example/Loan.groovy} | 26 +-
.../example/TraitDefaultValuesProxySpec.groovy | 189 ++++++
.../src/main/groovy/example/Auditable.groovy} | 26 +-
.../grails-app/conf/application.groovy | 13 +
.../groovy/specs/NoAnonymousFilterSpec.groovy | 105 +++
.../spring-security/ui/common/build.gradle | 2 +
.../binding/DateTimeRoundTripBindingSpec.groovy | 10 +-
.../web/converters/JSONConverterTests.groovy | 9 +-
.../org/grails/web/json/JSONWriterSpec.groovy | 62 --
grails-web-common/build.gradle | 1 +
.../org/grails/web/json/GrailsPrettyPrinter.java | 116 ++++
.../org/grails/web/json/HtmlSafeJsonWriter.java | 102 +++
.../groovy/org/grails/web/json/JSONTokener.java | 2 +-
.../groovy/org/grails/web/json/JSONWriter.java | 367 ++++++++---
.../org/grails/web/json/JsonMapperSupport.java | 244 +++++++
.../org/grails/web/json/JsonMapperValue.java | 86 +++
.../org/grails/web/json/NestedValueSerializer.java | 215 ++++++
.../web/json/PathCapturingJSONWriterWrapper.java | 136 +++-
.../org/grails/web/json/PrettyPrintJSONWriter.java | 138 +---
.../org/grails/web/json/parser/JSONParser.java | 7 +
.../grails/web/json/HtmlSafeJsonWriterSpec.groovy | 50 ++
.../org/grails/web/json/JSONArrayApiSpec.groovy | 322 +++++++++
.../org/grails/web/json/JSONObjectApiSpec.groovy | 345 ++++++++++
.../org/grails/web/json/JSONTokenerApiSpec.groovy | 245 +++++++
.../org/grails/web/json/JSONWriterApiSpec.groovy | 135 ++++
.../org/grails/web/json/JSONWriterSpec.groovy | 332 ++++++++++
.../PathCapturingJSONWriterWrapperApiSpec.groovy | 159 +++++
.../web/json/PrettyPrintJSONWriterApiSpec.groovy | 92 +++
.../BoundedCharsAsEncodedBytesCounterSpec.groovy | 167 +++++
.../web/util/IncludeResponseWrapperSpec.groovy | 181 +++++
.../org/grails/web/util/IncludedContentSpec.groovy | 88 +++
.../groovy/org/grails/web/util/WebUtilsSpec.groovy | 269 +++++++-
.../web/xml/PrettyPrintXMLStreamWriterSpec.groovy | 112 ++++
.../web/xml/StreamingMarkupWriterSpec.groovy | 76 +++
279 files changed, 19182 insertions(+), 3992 deletions(-)
diff --cc grails-doc/src/en/guide/upgrading/upgrading90x.adoc
index ed2f52e4d9,5c74d88d50..1b6afbe03a
--- a/grails-doc/src/en/guide/upgrading/upgrading90x.adoc
+++ b/grails-doc/src/en/guide/upgrading/upgrading90x.adoc
@@@ -144,170 -144,261 +144,429 @@@ Applications that use GPars directly, f
NOTE: Groovy 6 marks the concurrency toolkit as incubating. The Grails modules that build on it expose only the Grails `Promise` and `EventBus` contracts, so changes to the Groovy API in later Groovy releases are absorbed by Grails rather than by application code.
- ==== 2. Hibernate 7 Domain Binding
+ ==== 2. Groovy Code Is Compiled with invokedynamic
+
+ Grails 8 compiles every Groovy source set of an application without invokedynamic (`grails { indy = false }` was the default). Grails 9 leaves the setting unset, so the Groovy compiler's own default applies, and on Groovy 6 that is invokedynamic. An application that set `grails { indy = true }` can remove the line. Build logic that read the property, for example `grails.indy.get()`, must allow for it having no value now: use `grails.indy.getOrElse(true)` or check `grails.indy.present`.
+
+ An application that has to keep classic call sites, for example while it measures the difference, sets the property explicitly. An application that applies GraalVM's native image plugin cannot: the build fails with the reason, because an image needs invokedynamic.
+
+ To keep classic call sites:
+
+ [source,groovy]
+ .build.gradle
+ ----
+ grails {
+ indy = false
+ }
+ ----
+
+ Classic call sites on Groovy 6 need `org.apache.groovy:groovy-callsite` on the classpath. Grails does not carry it, so an application that sets `indy` to `false` declares `implementation 'org.apache.groovy:groovy-callsite'` itself, at the version the Grails BOM manages, and again for every source set that does not see its implementation dependencies, such as the test fixtures of Gradle's `java-test-fixtures` plugin. Without it the Groovy compiler stops with a message naming the module.
+
+ A library compiled with classic call sites needs the module too, whatever the application's own setting, because Groovy 6 loads such a class only with it; the failure is a `NoClassDefFoundError` naming `org.codehaus.groovy.runtime.callsite.CallSiteArray`. Spock 2.5, Geb 8 and the Asset Pipeline 5.2 are compiled with invokedynamic, but `org.testcontainers:testcontainers-spock` is not, so an application that uses it declares `testRuntimeOnly 'org.apache.groovy:groovy-callsite'` next to it.
+
+ ==== 3. `grails.converters.JSON` Can Write JSON With Spring Boot's JsonMapper
+
+ In Grails 9, `render ... as JSON`, `respond` for a JSON request and every other use of `grails.converters.JSON` still
+ render JSON as Grails 8 did, by default (see <<renderingJsonAsGrails8,Rendering JSON As Grails 8 Did>>). Setting
+ `grails.converters.json.legacy` to `false` makes the JSON converter write JSON through the application's Jackson
+ `JsonMapper`, the one Spring Boot auto-configures, so that it renders values as a Spring Boot application does. A later
+ release makes that the default, so check your application's JSON with the setting before you upgrade to it:
+
+ [source,yaml]
+ ----
+ grails:
+ converters:
+ json:
+ legacy: false
+ ----
+
+ While `grails.converters.json.legacy` is not set, Grails logs a warning once at startup that the default will change.
+ Setting it to either value turns the warning off.
+
+ With the setting `false`, the mapper writes the JSON text (numbers and pretty printing), and writes every single value
+ that it has a dedicated serializer for: dates and times, `Month`, `UUID`, `Locale`, `byte[]`, types with a `@JsonValue`,
+ and the types of any Jackson module registered with the application. Those values render as Spring Boot renders them,
+ and `spring.jackson.*` properties apply to them. For example, `spring.jackson.time-zone` writes `Date` and `Calendar`
+ values in that time zone, and converts `OffsetDateTime` and `ZonedDateTime` values to it. When the application context
+ has no `JsonMapper`, or has several and none is primary, as in a unit test, a default `JsonMapper` is used.
+
+ Parsing JSON does not change. `JSON.parse`, `request.JSON` and `new JSONObject(String)` parse with Grails' own
+ `JSONTokener`, as before: they accept the same syntax beyond strict JSON (single quotes, comments, unquoted values,
+ uppercase literals, trailing commas, `new Date(...)`), return the same number types (`Integer`, `Long`, `BigInteger`,
+ `Double` or `BigDecimal`, depending on the number) and the same `JSONObject` and `JSONArray` containers, which implement
+ `Map` and `List`.
+
+ With the setting `false`, Grails marshallers still render domain classes, beans, enums, collections, maps and arrays,
+ and now records (as an object of their components) and `Optional` (as its value), so the values they contain are
+ rendered as any other value is. A marshaller that an application registers, with `JSON.registerObjectMarshaller(...)` or an
+ `ObjectMarshallerRegisterer`, still takes precedence over the mapper for the types it supports.
+
+ A Jackson module registered with the application, such as a `JacksonModule` bean or a `@JacksonComponent` serializer,
+ applies to `grails.converters.JSON` with the setting `false`, where Grails 8 ignored it. When a module provides a serializer for a type that
+ Grails 8 rendered as a bean, the serializer renders it instead. The values that the serializer writes, such as a property
+ it writes with `JsonGenerator#writePOJO`, are rendered by the converter as any other value is, so registered marshallers,
+ enum names and the circular reference behaviour apply to them. A marshaller registered for the type itself takes
+ precedence over the module's serializer.
+
+ With the setting `false`, two things deliberately differ from Spring Boot, as they do in Grails 8:
+
+ * Enums, including one with a `@JsonValue`, render by `name()`, where Jackson 3 writes `toString()` or the `@JsonValue`,
+ so that the JSON binds back to the enum.
+ * Strings are escaped for an HTML `<script>` element: `</` is written as `<\u002f` (as `<\/` in a `GString` or a
+ `StreamCharBuffer`, as in Grails 8), and U+2028 and U+2029 as `\u2028` and `\u2029`. The parsed values are the same as
+ Spring Boot's.
+
+ With the setting `false`, the following values render differently than in Grails 8:
+
+ [cols="2,2,3", options="header"]
+ |===
+ | Value
+ | Grails 8, and Grails 9 by default
+ | `legacy: false`
+
+ | `OffsetTime`
+ | `"03:00:00-03:00"`, `"03:00:00.5+05:30"`
+ | `"03:00-03:00"`, `"03:00:00.500+05:30"`, from `OffsetTime#toString()`
+
+ | `Month`
+ | `"SEPTEMBER"`
+ | `9`, a JSON number. A `Month` binds back from its number.
+
+ | `java.util.Locale`
+ | `"zh_TW_#Hant"`, from `Locale#toString()`
+ | `"zh-Hant-TW"`, its language tag
+
+ | `char`, `Character`
+ | `{}`
+ | `"c"`
+
+ | `byte[]`
+ | `[1,2,3]`
+ | `"AQID"`, Base64
+
+ | `UUID`, `URI`, a type with a `@JsonValue` other than an enum
+ | an object of its bean properties
+ | its value, such as `"123e4567-e89b-12d3-a456-426614174000"`
+
+ | `java.util.regex.Pattern`, `java.nio.charset.Charset`, `java.net.InetAddress`
+ | an object of its bean properties
+ | its string, such as `"a+b"`, `"UTF-8"` or the host name
+
+ | `java.io.File`, `java.nio.file.Path`, `java.nio.ByteBuffer`
+ | a failure to render it
+ | `"/tmp/a.txt"`, `"file:///tmp/a.txt"`, and `"AQID"`, Base64
+
+ | `char[]`
+ | `[{},{}]`
+ | `"ab"`
+
+ | An enum constant with a body, whose class is a subclass of its enum
+ | an object of its bean properties
+ | its name, as any enum
+
+ | `tools.jackson.databind.JsonNode`
+ | an object of its bean properties
+ | the JSON it holds
+
+ | `Optional`
+ | `{"empty":false,"present":true}`
+ | its value, or `null` when it is empty
+
+ | A `NaN` or infinite `double`
+ | `NaN`, which is not valid JSON
+ | `"NaN"`
+
+ | Pretty printed JSON (`grails.converters.json.pretty.print`, `JSON#toString(true)`)
+ | `"a": 1`, with every array element on its own line, or, from `toString(true)`, indented by three spaces
+ | `"a" : 1`, the layout of the mapper's default pretty printer
+
+ | A single value, such as `render Role.HEAD as JSON`
+ | a `ConverterException`
+ | the JSON value, `"HEAD"`
+ |===
+
+ The other default date and time formats are the same as Grails 8.0.0's, which already renders `Date`, `Calendar`,
+ `java.sql.Date` and `java.sql.Timestamp` with millisecond precision and supports the additional date and time types.
+ With the setting `false`, map keys use the mapper's key serializers, instead of Grails' fixed date formats or the key's
+ `toString()`: a `Date` or `Calendar` key is written in the mapper's configured date format and time zone, a
+ `ZonedDateTime` or `OffsetDateTime` key keeps its own offset, as before, a `Class` key is its name
+ (`"java.lang.String"`, where Grails 8 wrote `"class java.lang.String"`), and the key of a type with a `@JsonValue` is
+ that value.
+
+ With the setting `false`, `JSON#toString(false)` does not indent the JSON when `grails.converters.json.pretty.print` is
+ `true`; Grails 8 ignored the argument. JSON that is not pretty printed is not indented either when the application's
+ `JsonMapper` indents its output (`spring.jackson.serialization.indent-output`).
+
+ With the setting `false`, the JSON marshallers that rendered these values are not registered. They are deprecated:
+ `DateMarshaller`, `CalendarMarshaller`, `ToStringBeanMarshaller`, `ByteArrayMarshaller`,
+ `InstantMarshaller`, `LocalDateMarshaller`, `LocalDateTimeMarshaller`, `OffsetDateTimeMarshaller` and
+ `ZonedDateTimeMarshaller`, in the `org.grails.web.converters.marshaller.json` package. To render one of these types
+ differently, register a marshaller for it, or configure the `JsonMapper`. The XML marshallers of the same names are not
+ changed. The default JSON marshallers have implicit priorities that follow their order (-1, -2, and so on), and with
+ the setting `false` that order differs, so a marshaller registered with an explicit negative priority may come before or
+ after different defaults.
+
+ Whatever the setting, `org.grails.web.json.JSONWriter`, which the converter and its marshallers write to, now writes
+ through a Jackson `JsonGenerator`, and `new JSONWriter(writer)` writes with a default `JsonMapper`:
+
+ * It keeps its public methods, rejects the same misplaced calls, and writes the same JSON text. It also accepts a single
+ value outside any object or array, where it threw a `JSONException`.
+ * The generator buffers the text. It reaches the `Writer` as the buffer fills, once the JSON text is complete, and when
+ `flush()` is called, rather than as each value is written. The `Writer` itself is not flushed or closed.
+ * `array()`, `object()`, `key()` and the `value` methods no longer go through the protected `append` and `comma`
+ methods. A subclass that overrides those to change the output, or writes to the `writer` field directly, must use the
+ public methods instead.
+ * `PrettyPrintJSONWriter` still indents as Grails 8 did, and is deprecated. Use
+ `new JSONWriter(writer, new JsonMapperSupport(jsonMapper), true)`, which indents with the mapper's default pretty printer.
+
+ The JavaCC JSON parser in `org.grails.web.json.parser` (`JSONParser`), which Grails does not use, is deprecated. Use
+ `JSON.parse` or `new JSONObject(String)`.
+
+ Whatever the setting, with the `PATH` circular reference behaviour (`grails.converters.json.circular.reference.behaviour`),
+ an object with a `null` property, or a single value, now renders instead of failing, and a reference that follows a
+ number now has the right path: `"root.x.other"` where Grails 8 wrote `"root.x.n"`, after a property `n` that is a
+ number.
+
+ JSON views, the XML converter and the HAL renderer are not changed.
+
+ [[renderingJsonAsGrails8]]
+ ===== Rendering JSON As Grails 8 Did
+
+ `grails.converters.json.legacy` is `true` by default in Grails 9. The JSON converter then renders values, including
+ domain classes, with the marshallers of Grails 8, formats map keys and indents pretty printed JSON as Grails 8 did, and
+ writes with a default `JsonMapper`, so that the application's `spring.jackson.*` settings and Jackson modules do not
+ change the text: `render ... as JSON` and `JSON#toString` return the same text as in Grails 8. What Grails 8 failed to
+ render, or rendered as invalid JSON, such as a single value, `NaN`, or a to-many association whose value is a `Map` with
+ other than one entry, renders as it does with the setting `false`. A reference that the `PATH` circular reference
+ behaviour writes after a number also has the right path, as described above, where Grails 8 wrote a wrong one. A later
+ release makes `false` the default; setting `grails.converters.json.legacy` to `true` explicitly keeps the Grails 8
+ rendering, and turns off the warning that Grails logs while it is not set. With
+ `grails.converters.json.domain.jackson.enabled` set to `true` as well, the JSON converter still renders as Grails 8 did,
+ and the application's `JsonMapper` renders domain classes with the module, as described below.
+
+ With the setting `false`, to keep the Grails 8 rendering of some types only, register a marshaller for each, for
+ example in `BootStrap.init`:
+
+ [source,groovy]
+ ----
+ JSON.registerObjectMarshaller(Month) { Month month -> month.name() }
+ JSON.registerObjectMarshaller(Locale) { Locale locale -> locale.toString() }
+ JSON.registerObjectMarshaller(byte[]) { byte[] bytes -> bytes as List }
+ ----
+
+ ==== 4. Domain Classes Can Render Through a Jackson Serializer
+
+ With `grails.converters.json.legacy` set to `false`, the JSON converter renders domain classes with a Jackson serializer,
+ `DomainClassSerializer`, as `DomainClassMarshaller` rendered them, with these changes:
+
+ * A property annotated with `@JsonIgnore`, or with `@JsonProperty(access = WRITE_ONLY)`, is no longer rendered.
+ * A to-many association whose value is a `Map` renders as an object of references, such as `{"a":{"id":1}}`, where it
+ failed before.
+ * `DomainClassMarshaller` and `DeepDomainClassMarshaller` render through the serializer. Their constructors and
+ protected methods (`includesProperty`, `excludesProperty`, `extractValue`, `asShortObject` and
+ `isRenderDomainClassRelations`) are unchanged, and a subclass that overrides them still renders as it did. They are
+ consulted before the mapper's value serializers, as `ProxyUnwrappingMarshaller` is.
+
+ The application's `JsonMapper` is not changed: writing a domain class instance with it, such as returning one from a
+ Spring MVC controller, renders it as a Jackson bean, as in Grails 8. To have the mapper render domain classes as
+ `render ... as JSON` does, set `grails.converters.json.domain.jackson.enabled` to `true`:
+
+ [source,yaml]
+ ----
+ grails:
+ converters:
+ json:
+ domain:
+ jackson:
+ enabled: true
+ ----
+
+ Grails then registers the serializer with the mapper, as a Jackson module, and the mapper renders associated instances as
+ references of their id, such as `{"id":3}`, rather than in full, and proxies as the instances they proxy. Of what
+ Jackson's bean serialization applies to a domain class, the serializer applies the following:
+
+ * It leaves out a property annotated with `@JsonIgnore`, or with `@JsonProperty(access = WRITE_ONLY)`, on its field or
+ getter, and the properties that a class-level `@JsonIgnoreProperties` names, such as those GORM names in the one it adds
+ to every domain class.
+ * It names the properties as Jackson does, by `@JsonProperty`, `@JsonNaming` and the mapper's naming strategy
+ (`spring.jackson.property-naming-strategy`), and names the id of a reference as the referenced class names it.
+ * It writes the type id of a domain class with `@JsonTypeInfo`. With `include = EXISTING_PROPERTY`, the type id is the
+ value of that property, so it is written only when the property is persistent; a transient or computed one is not.
+ * It writes the properties of a domain class instance in a `@JsonUnwrapped` property into the enclosing object. As with
+ Jackson's own unwrapping, an instance with a type id fails there, unless
+ `SerializationFeature.FAIL_ON_UNWRAPPED_TYPE_IDENTIFIERS` is disabled.
+ * A domain class with its own `@JsonSerialize` serializer, with a `@JsonValue`, or that implements `JacksonSerializable`
+ is written by Jackson, and so is a subclass of a domain class that is neither a domain class nor a proxy of one.
+
+ It applies nothing else. Null properties are written whatever `@JsonInclude` or
+ `spring.jackson.default-property-inclusion` say, properties are written in the converter's order rather than by
+ `@JsonPropertyOrder` or sorted alphabetically, and `@JsonView`, `@JsonFilter`, `@JsonAnyGetter`, `@JsonIgnoreType`,
+ `@JsonFormat` and `@JsonSerialize` on a property, and mix-ins, other than the property names they give, do not apply.
++
++==== 5. Hibernate 7 Domain Binding
+
+These notes apply to applications that use GORM for Hibernate 7 (`grails-hibernate7`).
+
- ===== 2.1 A Many-to-Many Without `belongsTo` Fails at Startup
++===== 5.1 A Many-to-Many Without `belongsTo` Fails at Startup
+
+A bidirectional many-to-many is written by its owning side, which `belongsTo` designates.
+When neither side declares `belongsTo`, both collections used to be bound as inverse, so no join table row was ever written and the relationship was silently lost.
+The application now refuses to start instead:
+
+[source,text]
+----
+Neither side of the many-to-many between [com.example.Author.books] and [com.example.Book.authors] declares belongsTo, so the relationship would never be stored. Declare belongsTo on the owned side, for example in Book: static belongsTo = Author
+----
+
+The message is a Hibernate `MappingException`.
+It names both sides of each affected relationship, and the sides in alphabetical order.
+
+Declare `belongsTo` on the side that should be owned:
+
+[source,groovy]
+----
+class Book {
+ String title
+ static hasMany = [authors: Author]
+ static belongsTo = Author
+}
+
+class Author {
+ String name
+ static hasMany = [books: Book]
+}
+----
+
+The same applies to a many-to-many from a class to itself: `belongsTo` names the class itself.
+A unidirectional many-to-many, a many-to-many that has `belongsTo` on either side, and one where either side is a `Map` need no change.
+The rule is enforced by native domain binding, see below.
+
+See link:{hibernate7Guide}index.html#gormAssociation-manyToMany[Many-to-Many Associations] in the GORM for Hibernate 7 manual.
+
- ===== 2.2 Fixes That Change Mappings and Generated Schemas
++===== 5.2 Fixes That Change Mappings and Generated Schemas
+
+The following defects of the Hibernate 7 mapping are fixed.
+They are also fixed in the 8.0.x line, so an application that is already on a recent Grails 8 release has seen them.
+
+* *`insertable: false` and `updatable: false`* were ignored on every property.
+ They are honored now: a column mapped `insertable: false` is left out of the `INSERT`, and one mapped `updatable: false` is left out of the `UPDATE`.
+ Review the domain classes that use them, because values that used to be written are now not written.
+* *Enum columns* did not receive the `comment`, `defaultValue`, `read` and `write` of their column mapping.
+ They do now, so the generated column definition of an enum property changes.
+ Compare the generated schema with your database before you use `dbCreate: update`.
+* *Collections of basic values* of an owner with more than one unidirectional `hasMany` were not written to their table.
+ The elements are now stored.
+ No change is needed.
+* *The inverse side of a many-to-many* read a join table of its own default name when only the owning side named the join table.
+ The inverse side now reads the table that the owner writes.
+ An empty table with the default name may remain in an existing database.
+
- ===== 2.3 Native Domain Binding
++===== 5.3 Native Domain Binding
+
+GORM for Hibernate 7 binds your domain classes with Hibernate's own annotation binder instead of building Hibernate's mapping itself.
+This is native domain binding, and in Grails {version} it is the only binding: an upgraded application starts with it without any setting.
+The classic binding of Grails 8 was removed, with the `hibernate.generatedDomainClasses` setting that selected it.
+An application that still sets the setting, with either value, starts normally and logs a warning at startup that names it; remove the setting.
+
+Your domain classes, your queries and the GORM API do not change.
+The mapping can, though:
+
+* Native binding refuses a mapping only when the classic binding could not use it either: the classic binding failed to start with it, or booted it and failed on the first row.
+ The refusal is an `UnsupportedOperationException` at startup that says what the classic binding did.
+ The manual chapter lists them.
+ The one exception is an embedded object as a part of a composite identifier, which the classic binding booted and native binding refuses with a message that points at a workaround that keeps the schema, see <<native-binding-embedded-id,2.5>>.
+* The generated schema differs from the one of the classic binding in a few documented cases, for example a `check (idx >= 0)` constraint on the index column of every list, and the column types of foreign keys to nested composite identifiers.
+* A few defects of the classic binding are not copied, such as a custom collection type on a `hasMany` being ignored.
+* A `hasMany` inside a class listed in `static embedded` that more than one embedded property embeds gets a collection table of its own for every owner.
+ The classic binding shared one table whose foreign key pointed at only one owner, so the collection of any other owner could not be stored, and it did not start when the properties had the same name.
+ The first owner (by entity name, then property path) keeps the table and the key column it has today, the others get names that start with their table and the path of the embedded property.
+* A custom collection type on a `hasMany` now takes effect, see <<native-binding-custom-collection-type,2.4>>.
+* A `createTable` change set written by `dbm-generate-gorm-changelog` or `dbm-gorm-diff` lists the columns in a different order: the identifier, then the columns in the order of the property names, then the foreign keys.
+ A diff against an existing database does not report this, because Liquibase does not compare column order.
+
+Before you upgrade an application with an existing database:
+
+. Start the upgraded application against a copy of the database and fix every refused mapping; the startup error says what to change.
+. Run `dbm-gorm-diff` against the copy with the upgraded application.
+ An empty diff means the upgrade does not change your schema.
+ Otherwise, compare each reported change with the schema differences in the manual and apply the ones you want through a migration.
+. Run your test suite once.
+
+There is no setting that brings the classic binding back.
+An application whose mappings or database need work stays on Grails 8 until it is done; every refused mapping is one the classic binding could not use either, so the change it needs is the same on both lines.
+
+The link:{hibernate7Guide}index.html#advancedGORMFeatures-nativeDomainBinding[Native Domain Binding] chapter of the GORM for Hibernate 7 manual lists every refused mapping, every schema difference and what each means for an existing database.
+
+[[native-binding-custom-collection-type]]
- ===== 2.4 Custom Collection Types Take Effect with Native Binding
++===== 5.4 Custom Collection Types Take Effect with Native Binding
+
+A `hasMany` of domain classes can name a Hibernate `UserCollectionType` as its `type`:
+
+[source,groovy]
+----
+class Author {
+ static hasMany = [books: Book]
+ static mapping = {
+ books type: MyCollectionType
+ }
+}
+----
+
+The classic binding of Grails 8 accepted this mapping and created the usual schema, but it never used the class.
+It did not even create an instance of `MyCollectionType`, and `author.books` was an ordinary Hibernate collection.
+
+Native binding applies the type.
+Hibernate creates, wraps and loads the collection with your class, so the code of your collection type runs where it never ran before.
+The schema is the same.
+
+If your application maps a custom collection type, test it with the upgraded application before you deploy.
+A type that was never exercised can fail or behave differently once it is used.
+
+A custom collection type on a `hasMany` of basic values is not supported (the classic binding did not boot it either).
+
+[[native-binding-embedded-id]]
- ===== 2.5 An Embedded Object as a Part of a Composite Identifier
++===== 5.5 An Embedded Object as a Part of a Composite Identifier
+
+Native binding refuses `id composite: ['code', 'address']` where `address` is listed in `static embedded`, because Hibernate cannot hold an embedded object in an identifier class.
+Declare the properties of the embedded class on the entity and name them in the identifier instead:
+
+[source,groovy]
+----
+class Customer implements Serializable {
+ String code
+ String addressStreet
+ String addressCity
+
+ static mapping = {
+ id composite: ['code', 'addressStreet', 'addressCity']
+ addressStreet column: 'address_street'
+ addressCity column: 'address_city'
+ }
+}
+----
+
+The table, its columns and its primary key are the ones the embedded version created with Grails 8 (`address_street` and `address_city` are the names the embedded object gave its columns), so an existing database needs no migration and its rows stay readable.
+A transient `Address getAddress()` accessor keeps `customer.address` working.
+The link:{hibernate7Guide}index.html#nativeDomainBinding-embeddedId[Native Domain Binding] chapter of the GORM for Hibernate 7 manual describes the accessor, the foreign keys to such an entity and how to switch an existing database.
+
+[[untyped-map-property]]
- ===== 2.6 A `Map` Property Needs Its Element Type
++===== 5.6 A `Map` Property Needs Its Element Type
+
+A `Map` property that is not a `hasMany` has to declare the type of its values:
+
+[source,groovy]
+----
+class Author {
+ String name
+
+ Map<String, String> homeLocation
+}
+----
+
+A property declared as a plain `Map` has no value type for Hibernate 7 to store.
+It does not work with either binding, and the declaration is not a new restriction of Grails {version}: Hibernate 7 has no type for a map whose values are `Object`.
+An application that only ran against Hibernate 5, for example one whose tests never boot the domain class, can still declare such a property.
+
+Declare the key and value types, `Map<String, String>` in the example, before you start the application on Hibernate 7.
+GORM maps are keyed by `String`.
+A map of domain classes is a `hasMany`, as before.