borinquenkid commented on code in PR #16572:
URL: https://github.com/apache/grails-core/pull/16572#discussion_r4238654727
##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/HibernateAlias.groovy:
##########
@@ -16,21 +16,21 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.grails.orm.hibernate.query;
+package org.grails.orm.hibernate.query
-import jakarta.persistence.criteria.JoinType;
+import groovy.transform.CompileStatic
+import jakarta.persistence.criteria.JoinType
-import org.grails.datastore.mapping.query.Query;
+import org.grails.datastore.mapping.query.Query
/**
* A internal criterion used to represent an alias for a basic collection join.
*
* @author walterduquedeestrada
*/
-public record HibernateAlias(String path, String alias, JoinType joinType)
+@CompileStatic
+@SuppressWarnings(['ClassStartsWithBlankLine', 'Indentation'])
+record HibernateAlias(String path, String alias, JoinType joinType)
implements Query.Criterion, Query.QueryElement {
- public HibernateAlias(String path, String alias) {
- this(path, alias, JoinType.INNER);
- }
}
Review Comment:
Fixed in ee3d2b0b58: the `HibernateAlias(String, String)` constructor is
back and defaults to `JoinType.INNER` (the one Groovy generated for the record
left `joinType` null).
##########
grails-data-hibernate7/core/src/main/groovy/grails/orm/HibernateCriteriaBuilder.groovy:
##########
@@ -125,133 +118,136 @@
* @see grails.gorm.DetachedCriteria
*/
@Slf4j
-@SuppressWarnings("PMD.AvoidDuplicateLiterals")
-public class HibernateCriteriaBuilder extends GroovyObjectSupport implements
BuildableCriteria, ProjectionList {
- private final SessionFactory sessionFactory;
- private final boolean participate;
- private final org.hibernate.query.criteria.HibernateCriteriaBuilder cb;
- private final HibernateQuery hibernateQuery;
- private Class<?> targetClass;
- private CriteriaQuery<?> criteriaQuery;
- private boolean uniqueResult = false;
-
- @SuppressWarnings("PMD.AvoidFieldNameMatchingMethodName")
- private boolean scroll;
-
- @SuppressWarnings("PMD.AvoidFieldNameMatchingMethodName")
- private boolean count;
-
- private boolean paginationEnabledList = false;
- private int defaultFlushMode;
-
- @SuppressWarnings("PMD.AvoidFieldNameMatchingMethodName")
- private boolean distinct = false;
- private CriteriaMethodInvoker criteriaMethodInvoker;
-
- @SuppressWarnings({"rawtypes", "PMD.CloseResource"})
- public HibernateCriteriaBuilder(Class targetClass, SessionFactory
sessionFactory, HibernateDatastore datastore) {
- this.targetClass = targetClass;
- setDatastore(datastore);
- this.sessionFactory = sessionFactory;
- this.cb = sessionFactory.getCriteriaBuilder();
+@SuppressWarnings('PMD.AvoidDuplicateLiterals')
+@CompileStatic
+class HibernateCriteriaBuilder extends GroovyObjectSupport implements
BuildableCriteria, ProjectionList {
+
+ private final SessionFactory sessionFactory
+ private final boolean participate
+ private final org.hibernate.query.criteria.HibernateCriteriaBuilder cb
+ private final HibernateQuery hibernateQuery
+ private Class<?> targetClass
+ private CriteriaQuery<?> criteriaQuery
+ private boolean uniqueResult = false
+
+ @SuppressWarnings('PMD.AvoidFieldNameMatchingMethodName')
+ private boolean scroll
+
+ @SuppressWarnings('PMD.AvoidFieldNameMatchingMethodName')
+ private boolean count
+
+ private boolean paginationEnabledList = false
+ private int defaultFlushMode
+
+ @SuppressWarnings('PMD.AvoidFieldNameMatchingMethodName')
+ private boolean distinct = false
+ private CriteriaMethodInvoker criteriaMethodInvoker
+
+ @SuppressWarnings(['rawtypes', 'PMD.CloseResource'])
+ HibernateCriteriaBuilder(Class targetClass, SessionFactory sessionFactory,
HibernateDatastore datastore) {
+ this.targetClass = targetClass
+ setDatastore(datastore)
+ this.sessionFactory = sessionFactory
+ this.cb = sessionFactory.getCriteriaBuilder()
if (TransactionSynchronizationManager.hasResource(sessionFactory)) {
- this.participate = true;
- } else {
- this.participate = false;
- org.hibernate.Session session = sessionFactory.openSession();
- TransactionSynchronizationManager.bindResource(sessionFactory, new
SessionHolder(session));
+ this.participate = true
}
- HibernateSession session = (HibernateSession) datastore.connect();
+ else {
+ this.participate = false
+ org.hibernate.Session session = sessionFactory.openSession()
+ TransactionSynchronizationManager.bindResource(sessionFactory, new
SessionHolder(session))
+ }
+ HibernateSession session = (HibernateSession) datastore.connect()
hibernateQuery = new HibernateQuery(
- session, (GrailsHibernatePersistentEntity)
datastore.getMappingContext().getPersistentEntity(targetClass.getName()));
- setDefaultFlushMode(GrailsHibernateTemplate.FLUSH_AUTO);
- criteriaMethodInvoker = new CriteriaMethodInvoker(this);
+ session, (GrailsHibernatePersistentEntity)
datastore.getMappingContext().getPersistentEntity(targetClass.getName()))
+ setDefaultFlushMode(GrailsHibernateTemplate.FLUSH_AUTO)
+ criteriaMethodInvoker = new CriteriaMethodInvoker(this)
}
- public static final String ALIAS_SEPARATOR = ":";
+ public static final String ALIAS_SEPARATOR = ':'
// The types a sqlProjection or sqlGroupProjection takes in the criteria
DSL, as on Hibernate 5
- public static final BasicTypeReference<?> BOOLEAN =
StandardBasicTypes.BOOLEAN;
- public static final BasicTypeReference<?> YES_NO =
StandardBasicTypes.YES_NO;
- public static final BasicTypeReference<?> BYTE = StandardBasicTypes.BYTE;
- public static final BasicTypeReference<?> CHARACTER =
StandardBasicTypes.CHARACTER;
- public static final BasicTypeReference<?> SHORT = StandardBasicTypes.SHORT;
- public static final BasicTypeReference<?> INTEGER =
StandardBasicTypes.INTEGER;
- public static final BasicTypeReference<?> LONG = StandardBasicTypes.LONG;
- public static final BasicTypeReference<?> FLOAT = StandardBasicTypes.FLOAT;
- public static final BasicTypeReference<?> DOUBLE =
StandardBasicTypes.DOUBLE;
- public static final BasicTypeReference<?> BIG_DECIMAL =
StandardBasicTypes.BIG_DECIMAL;
- public static final BasicTypeReference<?> BIG_INTEGER =
StandardBasicTypes.BIG_INTEGER;
- public static final BasicTypeReference<?> STRING =
StandardBasicTypes.STRING;
- public static final BasicTypeReference<?> NUMERIC_BOOLEAN =
StandardBasicTypes.NUMERIC_BOOLEAN;
- public static final BasicTypeReference<?> TRUE_FALSE =
StandardBasicTypes.TRUE_FALSE;
- public static final BasicTypeReference<?> URL = StandardBasicTypes.URL;
- public static final BasicTypeReference<?> TIME = StandardBasicTypes.TIME;
- public static final BasicTypeReference<?> DATE = StandardBasicTypes.DATE;
- public static final BasicTypeReference<?> TIMESTAMP =
StandardBasicTypes.TIMESTAMP;
- public static final BasicTypeReference<?> CALENDAR =
StandardBasicTypes.CALENDAR;
- public static final BasicTypeReference<?> CALENDAR_DATE =
StandardBasicTypes.CALENDAR_DATE;
- public static final BasicTypeReference<?> CLASS = StandardBasicTypes.CLASS;
- public static final BasicTypeReference<?> LOCALE =
StandardBasicTypes.LOCALE;
- public static final BasicTypeReference<?> CURRENCY =
StandardBasicTypes.CURRENCY;
- public static final BasicTypeReference<?> TIMEZONE =
StandardBasicTypes.TIMEZONE;
- public static final BasicTypeReference<?> UUID_BINARY =
StandardBasicTypes.UUID_BINARY;
- public static final BasicTypeReference<?> UUID_CHAR =
StandardBasicTypes.UUID_CHAR;
- public static final BasicTypeReference<?> BINARY =
StandardBasicTypes.BINARY;
- public static final BasicTypeReference<?> WRAPPER_BINARY =
StandardBasicTypes.BINARY_WRAPPER;
- public static final BasicTypeReference<?> IMAGE = StandardBasicTypes.IMAGE;
- public static final BasicTypeReference<?> BLOB = StandardBasicTypes.BLOB;
- public static final BasicTypeReference<?> MATERIALIZED_BLOB =
StandardBasicTypes.MATERIALIZED_BLOB;
- public static final BasicTypeReference<?> CHAR_ARRAY =
StandardBasicTypes.CHAR_ARRAY;
- public static final BasicTypeReference<?> CHARACTER_ARRAY =
StandardBasicTypes.CHARACTER_ARRAY;
- public static final BasicTypeReference<?> TEXT = StandardBasicTypes.TEXT;
- public static final BasicTypeReference<?> CLOB = StandardBasicTypes.CLOB;
- public static final BasicTypeReference<?> MATERIALIZED_CLOB =
StandardBasicTypes.MATERIALIZED_CLOB;
- public static final BasicTypeReference<?> SERIALIZABLE =
StandardBasicTypes.SERIALIZABLE;
+ static final BasicTypeReference<?> BOOLEAN = StandardBasicTypes.BOOLEAN
+ static final BasicTypeReference<?> YES_NO = StandardBasicTypes.YES_NO
+ static final BasicTypeReference<?> BYTE = StandardBasicTypes.BYTE
+ static final BasicTypeReference<?> CHARACTER = StandardBasicTypes.CHARACTER
+ static final BasicTypeReference<?> SHORT = StandardBasicTypes.SHORT
Review Comment:
Fixed in ee3d2b0b58: the 37 SQL projection type constants are `public static
final` fields again.
##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/GrailsHibernateUtil.groovy:
##########
@@ -0,0 +1,316 @@
+/*
+ * 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
+
+import groovy.transform.CompileStatic
+import org.hibernate.FlushMode
+import org.hibernate.Hibernate
+import org.hibernate.Session
+import org.hibernate.SessionFactory
+import org.hibernate.engine.spi.EntityEntry
+import org.hibernate.engine.spi.SessionImplementor
+import org.hibernate.engine.spi.Status
+import org.hibernate.internal.util.StringHelper
+import org.hibernate.proxy.HibernateProxy
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+
+import
org.springframework.transaction.support.TransactionSynchronizationManager
+
+import grails.gorm.annotation.Entity
+import org.grails.datastore.gorm.GormEntity
+import org.grails.datastore.mapping.model.PersistentEntity
+import org.grails.datastore.mapping.model.config.GormProperties
+import
org.grails.orm.hibernate.cfg.domainbinding.hibernate.GrailsHibernatePersistentEntity
+import org.grails.orm.hibernate.proxy.HibernateProxyHandler
+import org.grails.orm.hibernate.query.HibernateQueryArgument
+import org.grails.orm.hibernate.support.HibernateRuntimeUtils
+
+import java.lang.annotation.Annotation
+
+/**
+ * Utility methods for configuring Hibernate inside Grails.
+ *
+ * @author Graeme Rocher
+ * @since 0.4
+ */
+@CompileStatic
+class GrailsHibernateUtil extends HibernateRuntimeUtils {
+
+ /** @deprecated Use {@link
org.grails.orm.hibernate.query.HibernateQueryArgument#FETCH_SIZE} */
+ @Deprecated(since = '8.0', forRemoval = true)
+ static final String ARGUMENT_FETCH_SIZE =
HibernateQueryArgument.FETCH_SIZE.value()
Review Comment:
Fixed in ee3d2b0b58: the 14 deprecated constants are `public static final`
fields again.
##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/IdentityEnumType.groovy:
##########
@@ -0,0 +1,240 @@
+/*
+ * 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
+
+import groovy.transform.CompileStatic
+import org.hibernate.HibernateException
+import org.hibernate.MappingException
+import org.hibernate.engine.spi.SharedSessionContractImplementor
+import org.hibernate.type.descriptor.WrapperOptions
+import org.hibernate.type.descriptor.java.JavaType
+import org.hibernate.type.descriptor.jdbc.BigIntJdbcType
+import org.hibernate.type.descriptor.jdbc.IntegerJdbcType
+import org.hibernate.type.descriptor.jdbc.JdbcType
+import org.hibernate.type.descriptor.jdbc.VarcharJdbcType
+import org.hibernate.type.spi.TypeConfiguration
+import org.hibernate.usertype.ParameterizedType
+import org.hibernate.usertype.UserType
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+
+import java.lang.reflect.InvocationTargetException
+import java.lang.reflect.Method
+import java.sql.PreparedStatement
+import java.sql.ResultSet
+import java.sql.SQLException
+import java.sql.Types
+
+/**
+ * Hibernate 7 UserType to map Enums to their "id" value.
+ */
+@CompileStatic
+class IdentityEnumType implements UserType<Object>, ParameterizedType,
Serializable {
+
+ private static final Logger LOG = LoggerFactory.getLogger(IdentityEnumType)
+ private static final TypeConfiguration typeConfiguration = new
TypeConfiguration()
+
+ static final String ENUM_ID_ACCESSOR = 'getId'
+ static final String PARAM_ENUM_CLASS = 'enumClass'
Review Comment:
Fixed in ee3d2b0b58: `ENUM_ID_ACCESSOR` and `PARAM_ENUM_CLASS` are `public
static final` fields again.
##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/util/BackticksRemover.groovy:
##########
@@ -28,16 +29,21 @@
*
* @since 8.0
*/
-public class BackticksRemover implements Function<String, String> {
+@CompileStatic
+class BackticksRemover implements Function<String, String> {
- public static final String BACKTICK = "`";
+ static final String BACKTICK = '`'
Review Comment:
Fixed in ee3d2b0b58: `BACKTICK` is a `public static final` field again.
##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/support/ClosureEventTriggeringInterceptor.groovy:
##########
@@ -103,97 +99,96 @@ public class ClosureEventTriggeringInterceptor
* @deprecated Use {@link AbstractPersistenceEvent#ONLOAD_EVENT} instead
*/
@Deprecated
- public static final String ONLOAD_EVENT =
AbstractPersistenceEvent.ONLOAD_EVENT;
+ static final String ONLOAD_EVENT = AbstractPersistenceEvent.ONLOAD_EVENT
Review Comment:
Fixed in ee3d2b0b58: the 10 deprecated event constants are `public static
final` fields again.
##########
grails-data-hibernate7/spring-orm/src/main/groovy/org/grails/orm/hibernate/support/hibernate7/HibernateCallback.groovy:
##########
@@ -48,7 +46,6 @@ public interface HibernateCallback<T> {
* @throws HibernateException if thrown by the Hibernate API
* @see HibernateTemplate#execute
*/
- @Nullable
- T doInHibernate(Session session) throws HibernateException;
+ T doInHibernate(Session session) throws HibernateException
Review Comment:
Fixed in ee3d2b0b58: the jspecify `@Nullable` on `doInHibernate` is back,
and `JavaFacingApiSpec` (4b481384f6) pins it.
--
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]