From 44babcb880bec14955da7dd0898bebed3b72ab01 Mon Sep 17 00:00:00 2001 From: Karel Maesen Date: Tue, 21 Sep 2021 09:57:58 +0200 Subject: [PATCH] HHH-14738 Remove redundant function contribution --- .../spatial/testing/RequiresFunction.java | 2 +- ...tension.java => RequiresFunctionExtension.java} | 14 +++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) rename hibernate-spatial/src/test/java/org/hibernate/spatial/testing/{RequireFunctionExtension.java => RequiresFunctionExtension.java} (83%) diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/testing/RequiresFunction.java b/hibernate-spatial/src/test/java/org/hibernate/spatial/testing/RequiresFunction.java index d74c712e74..0702759ce5 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/testing/RequiresFunction.java +++ b/hibernate-spatial/src/test/java/org/hibernate/spatial/testing/RequiresFunction.java @@ -28,7 +28,7 @@ import org.junit.jupiter.api.extension.ExtendWith; @Target({ ElementType.METHOD, ElementType.TYPE, ElementType.ANNOTATION_TYPE }) @Retention(RetentionPolicy.RUNTIME) -@ExtendWith({ SessionFactoryExtension.class, RequireFunctionExtension.class }) +@ExtendWith({ SessionFactoryExtension.class, RequiresFunctionExtension.class }) public @interface RequiresFunction { /** * The key for the function (as used in the SqmFunctionRegistry) diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/testing/RequireFunctionExtension.java b/hibernate-spatial/src/test/java/org/hibernate/spatial/testing/RequiresFunctionExtension.java similarity index 83% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/testing/RequireFunctionExtension.java rename to hibernate-spatial/src/test/java/org/hibernate/spatial/testing/RequiresFunctionExtension.java index c3ffb48c7e..7b59a15ebc 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/testing/RequireFunctionExtension.java +++ b/hibernate-spatial/src/test/java/org/hibernate/spatial/testing/RequiresFunctionExtension.java @@ -23,12 +23,12 @@ import org.junit.jupiter.api.extension.ExtensionContext; import org.jboss.logging.Logger; -public class RequireFunctionExtension implements ExecutionCondition { +public class RequiresFunctionExtension implements ExecutionCondition { private static final ConditionEvaluationResult ENABLED = ConditionEvaluationResult.enabled( "No applicable @RequireFunction annotation" ); - private static final Logger log = Logger.getLogger( RequireFunctionExtension.class ); + private static final Logger log = Logger.getLogger( RequiresFunctionExtension.class ); @Override public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) { @@ -38,8 +38,6 @@ public class RequireFunctionExtension implements ExecutionCondition { return ENABLED; } - final SqmFunctionRegistry functionRegistry = new SqmFunctionRegistry(); - ExtensionContext.Store store = JUnitHelper.locateExtensionStore( SessionFactoryExtension.class, context, @@ -59,11 +57,9 @@ public class RequireFunctionExtension implements ExecutionCondition { if ( requiresFunctions.isPresent() ) { String functionKey = requiresFunctions.get().key(); - SpatialFunctionContributor contributor = new SpatialFunctionContributor(); - contributor.contributeFunctions( - functionRegistry, - existing.getSessionFactory().getServiceRegistry() - ); + SqmFunctionRegistry functionRegistry = existing.getSessionFactory() + .getQueryEngine() + .getSqmFunctionRegistry(); if ( functionRegistry.findFunctionDescriptor( functionKey ) == null ) { return ConditionEvaluationResult.disabled( String.format( Locale.ROOT,