borinquenkid commented on code in PR #16572:
URL: https://github.com/apache/grails-core/pull/16572#discussion_r4363530317


##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/CompositeUserTypeBinder.groovy:
##########
@@ -0,0 +1,265 @@
+/*
+ *  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
+ *
+ *  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.cfg.domainbinding.binder
+
+import java.beans.PropertyDescriptor
+import java.lang.reflect.Field
+import java.lang.reflect.Method
+import java.lang.reflect.Modifier
+import java.lang.reflect.RecordComponent
+import java.lang.reflect.Type
+
+import groovy.transform.CompileStatic
+import org.hibernate.MappingException
+import org.hibernate.boot.spi.MetadataBuildingContext
+import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment
+import org.hibernate.mapping.BasicValue
+import org.hibernate.mapping.Column
+import org.hibernate.mapping.Component
+import org.hibernate.mapping.PersistentClass
+import org.hibernate.mapping.Property
+import org.hibernate.mapping.Table
+import 
org.hibernate.property.access.internal.PropertyAccessStrategyCompositeUserTypeImpl
+import org.hibernate.property.access.spi.PropertyAccessStrategy
+import org.hibernate.usertype.CompositeUserType
+import org.jspecify.annotations.NonNull
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+import org.springframework.beans.BeanUtils
+import org.springframework.util.ReflectionUtils
+
+import org.grails.datastore.mapping.model.config.GormProperties
+import org.grails.datastore.mapping.reflect.ClassPropertyFetcher
+import org.grails.orm.hibernate.cfg.ColumnConfig
+import org.grails.orm.hibernate.cfg.GrailsHibernateUtil
+import org.grails.orm.hibernate.cfg.PersistentEntityNamingStrategy
+import org.grails.orm.hibernate.cfg.PropertyConfig
+import 
org.grails.orm.hibernate.cfg.domainbinding.hibernate.HibernatePersistentProperty
+import org.grails.orm.hibernate.cfg.domainbinding.util.BackticksRemover
+
+/**
+ * Binds a property mapped with a Hibernate {@link CompositeUserType} as a 
{@link Component} of that type, the way
+ * Hibernate's own annotation binder binds {@code @CompositeType}: one 
property per attribute of the user type's
+ * {@linkplain CompositeUserType#embeddable() embeddable class}, in 
alphabetical attribute order, each a basic value
+ * typed by reflection on the embeddable class and accessed through 
Hibernate's composite-user-type property access.
+ * The columns of the property mapping are assigned to the attributes in that 
order; an attribute without a configured
+ * column is named {@code <property>_<attribute>}.
+ *
+ * @since 8.0.1
+ */
+@CompileStatic
+class CompositeUserTypeBinder {

Review Comment:
   Done in 9f74af0796: `CompositeUserTypeBinder`, 
`CompositeUserTypeMappingSpec` and the `CompositeUserType` code in 
`GrailsDomainBinder`, `GrailsPropertyBinder` and `HibernatePersistentProperty` 
are out, with the matching changes to `GrailsPropertyBinderSpec`, 
`ListSecondPassBinderSpec`, `MapSecondPassBinderSpec`, 
`GrailsHibernatePersistentPropertySpec`, the two docs pages and the skill line. 
The affected files are the straightforward conversion of their `10.0.x` Java 
again; a grep for `CompositeUserType` finds only the sentence in 
`customHibernateTypes.adoc` that is on `10.0.x`. The classes get converted in 
the slice after #16695 reaches `10.0.x`.
   



##########
grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/MultipleUnidirectionalHasManySpec.groovy:
##########
@@ -0,0 +1,143 @@
+/*
+ *  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
+ *
+ *  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 grails.gorm.tests
+
+import grails.gorm.annotation.Entity
+
+/**
+ * An owner with several unidirectional hasMany associations keeps a join 
table for each of them, whether they point
+ * at different classes or at the same class with join tables of their own, 
and an element added to one of them is
+ * written to its own join table. A sibling to-many that is not bound as a 
collection, such as a serializable one,
+ * neither blocks the session factory nor counts as a sharer of the join table.
+ */
+class MultipleUnidirectionalHasManySpec extends HibernateGormDatastoreSpec {

Review Comment:
   Done in 9f74af0796: `MultipleUnidirectionalHasManySpec` is deleted, 
`CollectionKeyColumnUpdaterSpec` is the `10.0.x` content with only the quote 
style changed, and `CollectionKeyColumnUpdater` is the conversion of its 
`10.0.x` Java again, counting every unidirectional `HibernateToManyProperty` of 
the owner.
   



##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/PersistentEntityNamingStrategy.groovy:
##########
@@ -16,26 +16,27 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.grails.orm.hibernate.cfg;
+package org.grails.orm.hibernate.cfg
 
-import 
org.grails.orm.hibernate.cfg.domainbinding.hibernate.GrailsHibernatePersistentEntity;
-import 
org.grails.orm.hibernate.cfg.domainbinding.hibernate.HibernatePersistentProperty;
+import 
org.grails.orm.hibernate.cfg.domainbinding.hibernate.GrailsHibernatePersistentEntity
+import 
org.grails.orm.hibernate.cfg.domainbinding.hibernate.HibernatePersistentProperty
 
 /**
  * Allows plugging into to custom naming strategies
  *
  * @author Graeme Rocher
  * @since 5.0
  */
-public interface PersistentEntityNamingStrategy {
+interface PersistentEntityNamingStrategy {

Review Comment:
   Done in 9f74af0796: `PersistentEntityNamingStrategy` and the 14 tests and 
fixtures you listed have `@CompileStatic`, as has `HibernateDatabasePojoTest`. 
The annotation type `SnowflakeId` has no code and needs none. They compile as 
they are, and the `dbmigration-core` suite passes (41 tests).
   



##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/HibernateSession.groovy:
##########
@@ -76,8 +67,10 @@
  * @author Graeme Rocher
  * @since 1.0
  */
-@SuppressWarnings({"rawtypes", "PMD.DataflowAnomalyAnalysis", 
"PMD.AvoidDuplicateLiterals"})
-public class HibernateSession extends AbstractAttributeStoringSession 
implements QueryAliasAwareSession {
+// TODO(groovyism-cleanup): semicolons + double-quoted strings kept to 
preserve rename-similarity against the original .java (see matrei's review on 
#16576). Removed by the stacked groovyism-cleanup PR.

Review Comment:
   Done in 9f74af0796, for the whole tree: the `TODO(groovyism-cleanup)` 
comments and the `UnnecessarySemicolon`, `UnnecessaryGString` and PMD 
suppressions are gone, CodeNarc found the 4,401 semicolons and 198 plain double 
quoted strings that the suppressions hid, and they are fixed in the 146 files 
that had them (a small lexer that leaves strings and comments alone, validated 
by CodeNarc itself: `codenarcMain` is clean on all five modules with no 
suppression). The 175 `public` modifiers of `HibernateConnectionMetadata` are 
gone too. `codenarcTest` is skipped by the build, so the tests got the same 
pass, checked by compiling and running the suites. The idioms beyond the first 
two points of the style guide stay for the groovyism pull request, which sits 
before the next slice.
   



##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/util/OrderByClauseBuilder.groovy:
##########
@@ -16,110 +16,120 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.grails.orm.hibernate.cfg.domainbinding.util;
+package org.grails.orm.hibernate.cfg.domainbinding.util
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-import java.util.stream.Collectors;
+import groovy.transform.CompileStatic
+import groovy.transform.PackageScope
+import org.hibernate.boot.model.internal.BinderHelper
+import org.hibernate.mapping.PersistentClass
+import org.hibernate.mapping.Property
+import org.hibernate.mapping.SingleTableSubclass
+import org.hibernate.mapping.Selectable
 
-import org.hibernate.boot.model.internal.BinderHelper;
-import org.hibernate.mapping.PersistentClass;
-import org.hibernate.mapping.Property;
-import org.hibernate.mapping.SingleTableSubclass;
-
-import org.grails.datastore.mapping.model.DatastoreConfigurationException;
+import org.grails.datastore.mapping.model.DatastoreConfigurationException
 
 /** Utility class to build SQL order by clauses from HQL-style order by 
strings. */
-@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
-public class OrderByClauseBuilder {
+@CompileStatic
+@SuppressWarnings('PMD.DataflowAnomalyAnalysis')
+class OrderByClauseBuilder {
 
-    public String buildOrderByClause(
+    String buildOrderByClause(
             String hqlOrderBy, PersistentClass associatedClass, String role, 
String defaultOrder) {
         if (hqlOrderBy == null) {
-            return null;
+            return null
         }
 
         if (hqlOrderBy.isEmpty()) {
-            return associatedClass.getIdentifier().getSelectables().stream()
-                    .map(selectable -> selectable.getText() + " asc")
-                    .collect(Collectors.joining(", "));
+            List<String> parts = []
+            for (Selectable selectable : 
associatedClass.identifier.selectables) {
+                parts.add(selectable.text + ' asc')
+            }
+            return parts.join(', ')
         }
 
-        List<SortEntry> entries = parseSortEntries(hqlOrderBy, role, 
defaultOrder);
+        List<SortEntry> entries = parseSortEntries(hqlOrderBy, role, 
defaultOrder)
 
-        return entries.stream()
-                .map(entry -> buildPropertyOrderBy(entry, associatedClass))
-                .collect(Collectors.joining(", "));
+        List<String> parts = []
+        for (SortEntry entry : entries) {
+            parts.add(buildPropertyOrderBy(entry, associatedClass))
+        }
+        return parts.join(', ')
     }
 
     private List<SortEntry> parseSortEntries(String hqlOrderBy, String role, 
String defaultOrder) {
-        String[] tokens = hqlOrderBy.split("[ ,]+");
-        List<SortEntry> entries = new ArrayList<>();
-        SortEntry currentEntry = null;
+        String[] tokens = hqlOrderBy.split('[ ,]+')
+        List<SortEntry> entries = new ArrayList<>()
+        SortEntry currentEntry = null
 
         for (String token : tokens) {
-            if (token.isEmpty()) continue;
+            if (token.isEmpty()) {
+                continue
+            }
 
             if (isDirectionToken(token)) {
                 if (currentEntry == null || currentEntry.direction != null) {
                     throw new DatastoreConfigurationException(
-                            "Error while parsing sort clause: " + hqlOrderBy + 
" (" + role + ")");
+                            "Error while parsing sort clause: ${hqlOrderBy} 
(${role})".toString())
                 }
-                currentEntry.direction = token.toLowerCase(Locale.ROOT);
-            } else {
+                currentEntry.direction = token.toLowerCase(Locale.ROOT)

Review Comment:
   Done in 9f74af0796: `currentEntry.@direction = ...`, so the three writes are 
field writes. The `javap` sweep no longer lists `OrderByClauseBuilder`.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to