jdaugherty commented on code in PR #16572: URL: https://github.com/apache/grails-core/pull/16572#discussion_r4361364307
########## 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: This class, `CompositeUserTypeMappingSpec`, the `CompositeUserType` logic in `GrailsDomainBinder`, `GrailsPropertyBinder` and `HibernatePersistentProperty`, the changes to `GrailsPropertyBinderSpec`, `ListSecondPassBinderSpec`, `MapSecondPassBinderSpec` and `GrailsHibernatePersistentPropertySpec`, the `customHibernateTypes.adoc`, `type.adoc` and `upgrading80x.adoc` ยง26.11 changes and the `hibernate-developer` skill line are #16695, which is open on `8.0.x`, and this copy is behind its head (no `CompositeUserTypeColumns`). None of it is on `10.0.x`. A conversion PR can't carry it: when #16695 merges up, its `.java` files land next to these Groovy twins, and the feature is reviewed twice at two revisions. Please drop everything that comes from #16695; those classes get converted in the slice after it 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: Same for #16686, open on `8.0.x`: this spec, the `CollectionKeyColumnUpdaterSpec` changes and the join-table logic in `CollectionKeyColumnUpdater`. Please take them out and convert `CollectionKeyColumnUpdater` as it is on `10.0.x`. -- 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]
