This is an automated email from the ASF dual-hosted git repository. borinquenkid pushed a commit to branch 8.0.x-hibernate7 in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit 59a7b96fa5366475a44c0afb66a9ce0609e9894d Author: Walter Duque de Estrada <[email protected]> AuthorDate: Thu Jun 18 16:01:09 2026 -0500 Clean up H5 production source: @Deprecated(forRemoval), license header, logging, field order, @since - Add @Deprecated(forRemoval=true) to setBinder, populateArgumentsForCriteria(3-arg), ensureCorrectGroovyMetaClass in GrailsHibernateUtil and unwrapIfProxy, unwrapProxy in HibernateProxyHandler - Revert HibernateProxyHandler license header from URL-style back to ASF style - Remove verbose debug logging blocks from HibernateProxyHandler (logged trivially obvious branch outcomes on every proxy check call) - Remove unnecessary (Serializable) cast in HibernateProxyHandler.getIdentifier() (H5 AbstractLazyInitializer.getIdentifier() already returns Serializable) - Move JoinTable.column field declaration above the method block so all fields are grouped together before methods - Add @since 8.0 to PropertyConfig.hasJoinKeyMapping() and AbstractHibernateQuery.countResults() (new in this migration) Co-Authored-By: Claude Sonnet 4.6 <[email protected]> --- .../orm/hibernate/cfg/GrailsHibernateUtil.java | 6 +- .../org/grails/orm/hibernate/cfg/JoinTable.groovy | 10 +- .../grails/orm/hibernate/cfg/PropertyConfig.groovy | 3 + .../orm/hibernate/proxy/HibernateProxyHandler.java | 101 +++++---------------- .../hibernate/query/AbstractHibernateQuery.java | 3 + 5 files changed, 37 insertions(+), 86 deletions(-) diff --git a/grails-data-hibernate5/core/src/main/groovy/org/grails/orm/hibernate/cfg/GrailsHibernateUtil.java b/grails-data-hibernate5/core/src/main/groovy/org/grails/orm/hibernate/cfg/GrailsHibernateUtil.java index 009652d1e9..e5c4e8f700 100644 --- a/grails-data-hibernate5/core/src/main/groovy/org/grails/orm/hibernate/cfg/GrailsHibernateUtil.java +++ b/grails-data-hibernate5/core/src/main/groovy/org/grails/orm/hibernate/cfg/GrailsHibernateUtil.java @@ -178,7 +178,7 @@ public class GrailsHibernateUtil extends HibernateRuntimeUtils { /** * @deprecated No replacement. Do not use. */ - @Deprecated + @Deprecated(forRemoval = true) public static void setBinder(GrailsDomainBinder binder) { } @@ -190,7 +190,7 @@ public class GrailsHibernateUtil extends HibernateRuntimeUtils { * @param argMap The arguments map * */ - @Deprecated + @Deprecated(forRemoval = true) @SuppressWarnings("rawtypes") public static void populateArgumentsForCriteria(Class<?> targetClass, Criteria c, Map argMap, ConversionService conversionService) { populateArgumentsForCriteria(null, targetClass, c, argMap, conversionService); @@ -371,7 +371,7 @@ public class GrailsHibernateUtil extends HibernateRuntimeUtils { * @param target The GroovyObject * @param persistentClass The persistent class */ - @Deprecated + @Deprecated(forRemoval = true) public static void ensureCorrectGroovyMetaClass(Object target, Class<?> persistentClass) { if (target instanceof GroovyObject) { GroovyObject go = ((GroovyObject) target); diff --git a/grails-data-hibernate5/core/src/main/groovy/org/grails/orm/hibernate/cfg/JoinTable.groovy b/grails-data-hibernate5/core/src/main/groovy/org/grails/orm/hibernate/cfg/JoinTable.groovy index 45cfb36128..d471e09bfd 100644 --- a/grails-data-hibernate5/core/src/main/groovy/org/grails/orm/hibernate/cfg/JoinTable.groovy +++ b/grails-data-hibernate5/core/src/main/groovy/org/grails/orm/hibernate/cfg/JoinTable.groovy @@ -40,6 +40,11 @@ class JoinTable extends Table { */ List<ColumnConfig> keys = [] + /** + * The child id column + */ + ColumnConfig column + void setKeys(List<ColumnConfig> keys) { this.keys = keys } @@ -54,11 +59,6 @@ class JoinTable extends Table { return this } - /** - * The child id column - */ - ColumnConfig column - /** * Configures the column * @param columnConfig The column config diff --git a/grails-data-hibernate5/core/src/main/groovy/org/grails/orm/hibernate/cfg/PropertyConfig.groovy b/grails-data-hibernate5/core/src/main/groovy/org/grails/orm/hibernate/cfg/PropertyConfig.groovy index fcab77a84f..250a26cdb7 100644 --- a/grails-data-hibernate5/core/src/main/groovy/org/grails/orm/hibernate/cfg/PropertyConfig.groovy +++ b/grails-data-hibernate5/core/src/main/groovy/org/grails/orm/hibernate/cfg/PropertyConfig.groovy @@ -477,6 +477,9 @@ class PropertyConfig extends Property { return pc } + /** + * @since 8.0 + */ boolean hasJoinKeyMapping() { joinTable?.keys } diff --git a/grails-data-hibernate5/core/src/main/groovy/org/grails/orm/hibernate/proxy/HibernateProxyHandler.java b/grails-data-hibernate5/core/src/main/groovy/org/grails/orm/hibernate/proxy/HibernateProxyHandler.java index 7613689274..a0d03d7c39 100644 --- a/grails-data-hibernate5/core/src/main/groovy/org/grails/orm/hibernate/proxy/HibernateProxyHandler.java +++ b/grails-data-hibernate5/core/src/main/groovy/org/grails/orm/hibernate/proxy/HibernateProxyHandler.java @@ -1,18 +1,20 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. */ package org.grails.orm.hibernate.proxy; @@ -26,8 +28,6 @@ import org.hibernate.Hibernate; import org.hibernate.collection.spi.PersistentCollection; import org.hibernate.proxy.HibernateProxy; import org.hibernate.proxy.HibernateProxyHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.grails.datastore.gorm.proxy.ProxyInstanceMetaClass; import org.grails.datastore.mapping.core.Session; @@ -47,8 +47,6 @@ import org.grails.orm.hibernate.GrailsHibernateTemplate; */ public class HibernateProxyHandler implements ProxyHandler, ProxyFactory { - private static final Logger LOG = LoggerFactory.getLogger(HibernateProxyHandler.class); - /** * Check if the proxy or persistent collection is initialized. * {@inheritDoc} @@ -56,50 +54,22 @@ public class HibernateProxyHandler implements ProxyHandler, ProxyFactory { @Override public boolean isInitialized(Object o) { if (o == null) { - if (LOG.isDebugEnabled()) { - LOG.debug("isInitialized(Object) - object is null, returning false"); - } return false; } - - if (LOG.isDebugEnabled()) { - LOG.debug("isInitialized(Object) - checking object of type: {}", o.getClass().getName()); - } - if (o instanceof EntityProxy) { - boolean initialized = ((EntityProxy) o).isInitialized(); - if (LOG.isDebugEnabled()) { - LOG.debug("isInitialized(Object) - object is EntityProxy, isInitialized: {}", initialized); - } - return initialized; + return ((EntityProxy) o).isInitialized(); } if (o instanceof HibernateProxy) { - boolean initialized = !((HibernateProxy) o).getHibernateLazyInitializer().isUninitialized(); - if (LOG.isDebugEnabled()) { - LOG.debug("isInitialized(Object) - object is HibernateProxy, isInitialized: {}", initialized); - } - return initialized; + return !((HibernateProxy) o).getHibernateLazyInitializer().isUninitialized(); } if (o instanceof PersistentCollection) { - boolean initialized = ((PersistentCollection) o).wasInitialized(); - if (LOG.isDebugEnabled()) { - LOG.debug("isInitialized(Object) - object is PersistentCollection, wasInitialized: {}", initialized); - } - return initialized; + return ((PersistentCollection) o).wasInitialized(); } ProxyInstanceMetaClass proxyMc = getProxyInstanceMetaClass(o); if (proxyMc != null) { - boolean initialized = proxyMc.isProxyInitiated(); - if (LOG.isDebugEnabled()) { - LOG.debug("isInitialized(Object) - object is Groovy Proxy, isProxyInitiated: {}", initialized); - } - return initialized; - } - boolean initialized = Hibernate.isInitialized(o); - if (LOG.isDebugEnabled()) { - LOG.debug("isInitialized(Object) - Hibernate.isInitialized returned: {}", initialized); + return proxyMc.isProxyInitiated(); } - return initialized; + return Hibernate.isInitialized(o); } /** @@ -108,21 +78,11 @@ public class HibernateProxyHandler implements ProxyHandler, ProxyFactory { */ @Override public boolean isInitialized(Object obj, String associationName) { - if (LOG.isDebugEnabled()) { - LOG.debug("isInitialized(Object, String) - checking association '{}' on object of type: {}", associationName, obj != null ? obj.getClass().getName() : "null"); - } try { Object proxy = ClassPropertyFetcher.getInstancePropertyValue(obj, associationName); - boolean initialized = isInitialized(proxy); - if (LOG.isDebugEnabled()) { - LOG.debug("isInitialized(Object, String) - association '{}' isInitialized: {}", associationName, initialized); - } - return initialized; + return isInitialized(proxy); } catch (RuntimeException e) { - if (LOG.isDebugEnabled()) { - LOG.debug("isInitialized(Object, String) - RuntimeException occurred while checking association '{}', returning false", associationName); - } return false; } } @@ -163,7 +123,7 @@ public class HibernateProxyHandler implements ProxyHandler, ProxyFactory { return proxyMc.getKey(); } if (o instanceof HibernateProxy) { - return (Serializable) ((HibernateProxy) o).getHibernateLazyInitializer().getIdentifier(); + return ((HibernateProxy) o).getHibernateLazyInitializer().getIdentifier(); } else { return null; @@ -184,7 +144,7 @@ public class HibernateProxyHandler implements ProxyHandler, ProxyFactory { * @see #unwrap(Object) * @deprecated use unwrap */ - @Deprecated + @Deprecated(forRemoval = true) public Object unwrapIfProxy(Object instance) { return unwrap(instance); } @@ -221,30 +181,15 @@ public class HibernateProxyHandler implements ProxyHandler, ProxyFactory { } private ProxyInstanceMetaClass getProxyInstanceMetaClass(Object o) { - if (LOG.isDebugEnabled()) { - LOG.debug("getProxyInstanceMetaClass() - checking if object is GroovyObject: {}", o != null ? o.getClass().getName() : "null"); - } if (o instanceof GroovyObject) { MetaClass mc = ((GroovyObject) o).getMetaClass(); - if (LOG.isDebugEnabled()) { - LOG.debug("getProxyInstanceMetaClass() - metaClass type: {}", mc.getClass().getName()); - } if (mc instanceof HandleMetaClass) { mc = ((HandleMetaClass) mc).getAdaptee(); - if (LOG.isDebugEnabled()) { - LOG.debug("getProxyInstanceMetaClass() - handleMetaClass adaptee type: {}", mc.getClass().getName()); - } } if (mc instanceof ProxyInstanceMetaClass) { - if (LOG.isDebugEnabled()) { - LOG.debug("getProxyInstanceMetaClass() - found ProxyInstanceMetaClass"); - } return (ProxyInstanceMetaClass) mc; } } - if (LOG.isDebugEnabled()) { - LOG.debug("getProxyInstanceMetaClass() - no ProxyInstanceMetaClass found"); - } return null; } @@ -268,7 +213,7 @@ public class HibernateProxyHandler implements ProxyHandler, ProxyFactory { /** * @deprecated use unwrap */ - @Deprecated + @Deprecated(forRemoval = true) public Object unwrapProxy(Object proxy) { return unwrap(proxy); } diff --git a/grails-data-hibernate5/core/src/main/groovy/org/grails/orm/hibernate/query/AbstractHibernateQuery.java b/grails-data-hibernate5/core/src/main/groovy/org/grails/orm/hibernate/query/AbstractHibernateQuery.java index ae28be7b93..631c85a1c4 100644 --- a/grails-data-hibernate5/core/src/main/groovy/org/grails/orm/hibernate/query/AbstractHibernateQuery.java +++ b/grails-data-hibernate5/core/src/main/groovy/org/grails/orm/hibernate/query/AbstractHibernateQuery.java @@ -569,6 +569,9 @@ public abstract class AbstractHibernateQuery extends Query { return hibernateProjectionList; } + /** + * @since 8.0 + */ @Override public Number countResults() { if (hibernateProjectionList != null && !hibernateProjectionList.isEmpty()) {
