From 958cdfb09f105f619c4cf54cf55e240cafaa5706 Mon Sep 17 00:00:00 2001 From: Gavin King Date: Wed, 8 Feb 2023 15:50:33 +0100 Subject: [PATCH] remove an obsolete constructor no longer called by Quarkus and delete the stupid InformixDialectTestCase --- .../dialect/InformixDialectTestCase.java | 124 ------------------ .../org/hibernate/query/spi/QueryEngine.java | 68 ---------- 2 files changed, 192 deletions(-) delete mode 100644 hibernate-community-dialects/src/test/java/org/hibernate/community/dialect/InformixDialectTestCase.java diff --git a/hibernate-community-dialects/src/test/java/org/hibernate/community/dialect/InformixDialectTestCase.java b/hibernate-community-dialects/src/test/java/org/hibernate/community/dialect/InformixDialectTestCase.java deleted file mode 100644 index 0ef6f369a7..0000000000 --- a/hibernate-community-dialects/src/test/java/org/hibernate/community/dialect/InformixDialectTestCase.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.community.dialect; - -import org.hibernate.boot.registry.StandardServiceRegistry; -import org.hibernate.boot.registry.StandardServiceRegistryBuilder; -import org.hibernate.metamodel.model.domain.internal.JpaMetamodelImpl; -import org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl; -import org.hibernate.metamodel.spi.MappingMetamodelImplementor; -import org.hibernate.query.criteria.ValueHandlingMode; -import org.hibernate.query.internal.NamedObjectRepositoryImpl; -import org.hibernate.query.spi.QueryEngine; -import org.hibernate.query.sqm.function.SelfRenderingSqmFunction; -import org.hibernate.query.sqm.function.SqmFunctionDescriptor; -import org.hibernate.sql.ast.spi.SqlAppender; -import org.hibernate.sql.ast.spi.StringBuilderSqlAppender; -import org.hibernate.testing.boot.MetadataBuildingContextTestingImpl; -import org.hibernate.type.BasicType; -import org.hibernate.type.descriptor.java.JdbcDateJavaType; -import org.hibernate.type.descriptor.java.JdbcTimestampJavaType; -import org.hibernate.type.descriptor.jdbc.DateJdbcType; -import org.hibernate.type.descriptor.jdbc.TimestampJdbcType; -import org.hibernate.type.spi.TypeConfiguration; - -import org.hibernate.testing.TestForIssue; -import org.hibernate.testing.junit4.BaseUnitTestCase; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -import static java.util.Collections.emptyList; -import static java.util.Collections.emptyMap; -import static org.hibernate.engine.query.internal.NativeQueryInterpreterStandardImpl.NATIVE_QUERY_INTERPRETER; -import static org.junit.Assert.assertEquals; - -/** - * Testing of patched support for Informix boolean type; see HHH-9894, HHH-10800 - * - * @author Greg Jones - */ -public class InformixDialectTestCase extends BaseUnitTestCase { - - private static final InformixDialect dialect = new InformixDialect(); - private static StandardServiceRegistry ssr; - private static QueryEngine queryEngine; - private static MappingMetamodelImplementor mappingMetamodel; - private static TypeConfiguration typeConfiguration; - - @BeforeClass - public static void init() { - ssr = new StandardServiceRegistryBuilder().build(); - typeConfiguration = new TypeConfiguration(); - typeConfiguration.scope( new MetadataBuildingContextTestingImpl( ssr ) ); - mappingMetamodel = new MappingMetamodelImpl( typeConfiguration, ssr ); - final JpaMetamodelImpl jpaMetamodel = new JpaMetamodelImpl( typeConfiguration, mappingMetamodel, ssr ); - queryEngine = new QueryEngine( - null, - null, - jpaMetamodel, - ValueHandlingMode.BIND, - dialect.getPreferredSqlTypeCodeForBoolean(), - false, - new NamedObjectRepositoryImpl( emptyMap(), emptyMap(), emptyMap(), emptyMap() ), - NATIVE_QUERY_INTERPRETER, - dialect, - ssr - ); - } - - @AfterClass - public static void tearDown() { - queryEngine.close(); - ssr.close(); - } - - @Test - @TestForIssue(jiraKey = "HHH-9894") - public void testToBooleanValueStringTrue() { - assertEquals( "'t'", dialect.toBooleanValueString( true ) ); - } - - @Test - @TestForIssue(jiraKey = "HHH-9894") - public void testToBooleanValueStringFalse() { - assertEquals( "'f'", dialect.toBooleanValueString( false ) ); - } - - @Test - @TestForIssue(jiraKey = "HHH-10800") - public void testCurrentTimestampFunction() { - SqmFunctionDescriptor functionDescriptor = queryEngine.getSqmFunctionRegistry() - .findFunctionDescriptor( "current_timestamp" ); - SelfRenderingSqmFunction sqmExpression = - functionDescriptor.generateSqmExpression( null, queryEngine, typeConfiguration ); - BasicType basicType = (BasicType) sqmExpression.getNodeType(); - assertEquals( JdbcTimestampJavaType.INSTANCE, basicType.getJavaTypeDescriptor() ); - assertEquals( TimestampJdbcType.INSTANCE, basicType.getJdbcType() ); - - SqlAppender appender = new StringBuilderSqlAppender(); - sqmExpression.getRenderingSupport().render( appender, emptyList(), null ); - assertEquals( "current", appender.toString() ); - } - - @Test - @TestForIssue(jiraKey = "HHH-10800") - public void testCurrentDateFunction() { - SqmFunctionDescriptor functionDescriptor = queryEngine.getSqmFunctionRegistry() - .findFunctionDescriptor( "current_date" ); - SelfRenderingSqmFunction sqmExpression = - functionDescriptor.generateSqmExpression( null, queryEngine, typeConfiguration ); - BasicType basicType = (BasicType) sqmExpression.getNodeType(); - assertEquals( JdbcDateJavaType.INSTANCE, basicType.getJavaTypeDescriptor() ); - assertEquals( DateJdbcType.INSTANCE, basicType.getJdbcType() ); - - SqlAppender appender = new StringBuilderSqlAppender(); - sqmExpression.getRenderingSupport().render( appender, emptyList(), null ); - assertEquals( "today", appender.toString() ); - } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/query/spi/QueryEngine.java b/hibernate-core/src/main/java/org/hibernate/query/spi/QueryEngine.java index 3426ecd283..2832dd6cb5 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/spi/QueryEngine.java +++ b/hibernate-core/src/main/java/org/hibernate/query/spi/QueryEngine.java @@ -9,7 +9,6 @@ package org.hibernate.query.spi; import java.util.ArrayList; import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.function.Supplier; import org.hibernate.Incubating; @@ -21,20 +20,16 @@ import org.hibernate.boot.spi.MetadataImplementor; import org.hibernate.boot.spi.SessionFactoryOptions; import org.hibernate.cfg.AvailableSettings; import org.hibernate.dialect.Dialect; -import org.hibernate.engine.config.spi.ConfigurationService; import org.hibernate.engine.query.spi.NativeQueryInterpreter; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.internal.CoreLogging; import org.hibernate.internal.util.config.ConfigurationHelper; -import org.hibernate.metamodel.model.domain.spi.JpaMetamodelImplementor; -import org.hibernate.query.criteria.ValueHandlingMode; import org.hibernate.query.hql.HqlTranslator; import org.hibernate.query.hql.internal.StandardHqlTranslator; import org.hibernate.query.hql.spi.SqmCreationOptions; import org.hibernate.query.internal.QueryInterpretationCacheDisabledImpl; import org.hibernate.query.internal.QueryInterpretationCacheStandardImpl; import org.hibernate.query.named.NamedObjectRepository; -import org.hibernate.query.sqm.NodeBuilder; import org.hibernate.query.sqm.function.SqmFunctionRegistry; import org.hibernate.query.sqm.internal.SqmCreationOptionsStandard; import org.hibernate.query.sqm.internal.SqmCriteriaNodeBuilder; @@ -150,69 +145,6 @@ public class QueryEngine { ); } - /** - * Simplified constructor mainly meant for Quarkus use - */ - public QueryEngine( - String uuid, - String name, - JpaMetamodelImplementor jpaMetamodel, - ValueHandlingMode criteriaValueHandlingMode, - int preferredSqlTypeCodeForBoolean, - boolean useStrictJpaCompliance, - NamedObjectRepository namedObjectRepository, - NativeQueryInterpreter nativeQueryInterpreter, - Dialect dialect, - ServiceRegistry serviceRegistry) { - this.namedObjectRepository = Objects.requireNonNull( namedObjectRepository ); - this.sqmTranslatorFactory = null; - this.nativeQueryInterpreter = Objects.requireNonNull( nativeQueryInterpreter ); - this.sqmFunctionRegistry = new SqmFunctionRegistry(); - this.typeConfiguration = jpaMetamodel.getTypeConfiguration(); - - dialect.contributeFunctions( new FunctionContributionsImpl( serviceRegistry, typeConfiguration, sqmFunctionRegistry ) ); - - this.interpretationCache = buildInterpretationCache( - () -> serviceRegistry.getService( StatisticsImplementor.class ), - serviceRegistry.getService( ConfigurationService.class ).getSettings() - ); - - this.criteriaBuilder = new SqmCriteriaNodeBuilder( - uuid, - name, - this, - useStrictJpaCompliance, - criteriaValueHandlingMode, - serviceRegistry, - typeConfiguration::getSessionFactory - ); - - this.hqlTranslator = new StandardHqlTranslator( - new SqmCreationContext() { - @Override - public JpaMetamodelImplementor getJpaMetamodel() { - return jpaMetamodel; - } - - @Override - public ServiceRegistry getServiceRegistry() { - return serviceRegistry; - } - - @Override - public QueryEngine getQueryEngine() { - return QueryEngine.this; - } - - @Override - public NodeBuilder getNodeBuilder() { - return criteriaBuilder; - } - }, - () -> useStrictJpaCompliance - ); - } - private static HqlTranslator resolveHqlTranslator( QueryEngineOptions runtimeOptions, Dialect dialect,