HHH-14738 Remove redundant function contribution

This commit is contained in:
Karel Maesen 2021-09-21 09:57:58 +02:00
parent b88596df6a
commit 44babcb880
2 changed files with 6 additions and 10 deletions

View File

@ -28,7 +28,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
@Target({ ElementType.METHOD, ElementType.TYPE, ElementType.ANNOTATION_TYPE }) @Target({ ElementType.METHOD, ElementType.TYPE, ElementType.ANNOTATION_TYPE })
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@ExtendWith({ SessionFactoryExtension.class, RequireFunctionExtension.class }) @ExtendWith({ SessionFactoryExtension.class, RequiresFunctionExtension.class })
public @interface RequiresFunction { public @interface RequiresFunction {
/** /**
* The key for the function (as used in the SqmFunctionRegistry) * The key for the function (as used in the SqmFunctionRegistry)

View File

@ -23,12 +23,12 @@ import org.junit.jupiter.api.extension.ExtensionContext;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
public class RequireFunctionExtension implements ExecutionCondition { public class RequiresFunctionExtension implements ExecutionCondition {
private static final ConditionEvaluationResult ENABLED = ConditionEvaluationResult.enabled( private static final ConditionEvaluationResult ENABLED = ConditionEvaluationResult.enabled(
"No applicable @RequireFunction annotation" ); "No applicable @RequireFunction annotation" );
private static final Logger log = Logger.getLogger( RequireFunctionExtension.class ); private static final Logger log = Logger.getLogger( RequiresFunctionExtension.class );
@Override @Override
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) { public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
@ -38,8 +38,6 @@ public class RequireFunctionExtension implements ExecutionCondition {
return ENABLED; return ENABLED;
} }
final SqmFunctionRegistry functionRegistry = new SqmFunctionRegistry();
ExtensionContext.Store store = JUnitHelper.locateExtensionStore( ExtensionContext.Store store = JUnitHelper.locateExtensionStore(
SessionFactoryExtension.class, SessionFactoryExtension.class,
context, context,
@ -59,11 +57,9 @@ public class RequireFunctionExtension implements ExecutionCondition {
if ( requiresFunctions.isPresent() ) { if ( requiresFunctions.isPresent() ) {
String functionKey = requiresFunctions.get().key(); String functionKey = requiresFunctions.get().key();
SpatialFunctionContributor contributor = new SpatialFunctionContributor(); SqmFunctionRegistry functionRegistry = existing.getSessionFactory()
contributor.contributeFunctions( .getQueryEngine()
functionRegistry, .getSqmFunctionRegistry();
existing.getSessionFactory().getServiceRegistry()
);
if ( functionRegistry.findFunctionDescriptor( functionKey ) == null ) { if ( functionRegistry.findFunctionDescriptor( functionKey ) == null ) {
return ConditionEvaluationResult.disabled( String.format( return ConditionEvaluationResult.disabled( String.format(
Locale.ROOT, Locale.ROOT,