jamesfredley commented on code in PR #16480: URL: https://github.com/apache/grails-core/pull/16480#discussion_r4174316840
########## grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/UserTypeMappingSpec.groovy: ########## @@ -0,0 +1,204 @@ +/* + * 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 + +import java.sql.PreparedStatement +import java.sql.ResultSet +import java.sql.SQLException +import java.sql.Types + +import groovy.transform.CompileStatic + +import grails.gorm.annotation.Entity +import grails.gorm.hibernate.HibernateEntity +import org.grails.datastore.mapping.core.DatastoreUtils +import org.grails.orm.hibernate.cfg.Settings +import org.hibernate.mapping.SimpleValue +import org.hibernate.type.descriptor.WrapperOptions +import org.hibernate.usertype.UserType +import spock.lang.Specification +import spock.lang.Unroll + +class UserTypeMappingSpec extends Specification { + + @Unroll + void "a user-type in the default mapping given as #description applies to every entity"() { Review Comment: The default-mapping test says the user type applies to every entity, but only `UserTypeFlag` is registered. The class-local case (line 81) and the precedence case (line 97) also distinguish scope mainly through `typeNameOf`, which reads Hibernate metadata. A Boolean round-trip alone would still pass if the custom type were not bound. Non-blocking follow-up: register and persist two entities in the default case, persist the unaffected entity in the class-local case, and assert standard physical Boolean storage for the unaffected and overridden properties. The Class-versus-string regression itself is already covered by the save/read and the `Y`/`N` column checks. -- 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]
