borinquenkid commented on code in PR #15568: URL: https://github.com/apache/grails-core/pull/15568#discussion_r3453914100
########## grails-data-hibernate7/grails-plugin/src/main/groovy/grails/test/hibernate/HibernateSpec.groovy: ########## @@ -4,25 +4,28 @@ * 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 + * '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 + * 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY Review Comment: Checking this — will confirm. ########## grails-data-hibernate7/grails-plugin/src/main/groovy/grails/test/hibernate/HibernateSpec.groovy: ########## @@ -56,36 +74,124 @@ abstract class HibernateSpec extends Specification { @Shared @AutoCleanup HibernateDatastore hibernateDatastore @Shared PlatformTransactionManager transactionManager + @Shared HibernateProxyHandler proxyHandler = new HibernateProxyHandler() + @Shared @AutoCleanup('close') ApplicationContext applicationContext - void setupSpec() { + static class TestGrailsBytecodeProvider extends GrailsBytecodeProvider { - List<PropertySourceLoader> propertySourceLoaders = SpringFactoriesLoader.loadFactories(PropertySourceLoader, getClass().getClassLoader()) - ResourceLoader resourceLoader = new DefaultResourceLoader() - MutablePropertySources propertySources = new MutablePropertySources() - PropertySourceLoader ymlLoader = propertySourceLoaders.find { it.getFileExtensions().toList().contains('yml') } - if (ymlLoader) { - load(resourceLoader, ymlLoader, 'application.yml').each { - propertySources.addLast(it) - } - } - PropertySourceLoader groovyLoader = propertySourceLoaders.find { it.getFileExtensions().toList().contains('groovy') } - if (groovyLoader) { - load(resourceLoader, groovyLoader, 'application.groovy').each { - propertySources.addLast(it) + @Override + @CompileStatic(TypeCheckingMode.SKIP) + protected ByteBuddyProxyHelper createProxyHelper() { + try { + def byteBuddyStateClass = Class.forName('org.hibernate.bytecode.internal.bytebuddy.ByteBuddyState') + def byteBuddyStateConstructor = byteBuddyStateClass.getDeclaredConstructor() + byteBuddyStateConstructor.setAccessible(true) + def byteBuddyState = byteBuddyStateConstructor.newInstance() + return new ByteBuddyProxyHelper(byteBuddyState as org.hibernate.bytecode.internal.bytebuddy.ByteBuddyState) + } catch (e) { Review Comment: Will address both points. ########## grails-data-hibernate7/grails-plugin/src/main/groovy/grails/test/hibernate/HibernateSpec.groovy: ########## Review Comment: Agreed — will move it. ########## grails-data-hibernate7/grails-plugin/src/main/groovy/grails/test/hibernate/HibernateSpec.groovy: ########## @@ -108,8 +214,43 @@ abstract class HibernateSpec extends Specification { /** * @return The configuration */ - Map getConfiguration() { - Collections.singletonMap(Settings.SETTING_DB_CREATE, 'create-drop') + Map<String,Object> getConfiguration() { + [ + (Settings.SETTING_DB_CREATE): 'create-drop', + 'hibernate.proxy_factory_class': 'org.grails.orm.hibernate.proxy.ByteBuddyGroovyProxyFactory', + 'hibernate.dialect': 'org.hibernate.dialect.H2Dialect', + 'jakarta.persistence.validation.mode': 'none' + ] as Map<String, Object> + } + + @CompileStatic(TypeCheckingMode.SKIP) Review Comment: Will explain / address. -- 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]
