Interface FunctionContributor

All Known Implementing Classes:
SpatialFunctionContributor

@JavaServiceLoadable @SPI({USE,IMPLEMENT,SUPPLY}) public interface FunctionContributor

Contributes custom HQL functions to the eventual SqmFunctionRegistry.

A provider normally exposes its implementation through the Java ServiceLoader facility. An application may instead supply one through Configuration.registerFunctionContributor(FunctionContributor) or MetadataBuilder.applyFunctions(FunctionContributor).

Complete all registration during contributeFunctions(FunctionContributions). Do not retain the supplied FunctionContributions or its mutable registry beyond the callback. Use a contributor for application- or library-wide functions; a Dialect should instead override Dialect.initializeFunctionRegistry(FunctionContributions).

Contributors are invoked in ascending ordinal() order. Higher ordinals therefore replace registrations made under the same key by lower ordinals.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Contribute functions
    default int
    Determines order in which the contributions will be applied (lowest ordinal first).
  • Method Details

    • contributeFunctions

      void contributeFunctions(FunctionContributions functionContributions)
      Contribute functions
      Parameters:
      functionContributions - The target for the contributions
    • ordinal

      default int ordinal()
      Determines order in which the contributions will be applied (lowest ordinal first).

      The range 0-500 is reserved for Hibernate, range 500-1000 for libraries and 1000-Integer.MAX_VALUE for user-defined FunctionContributors.

      Contributions from higher precedence contributors (higher numbers) effectively override contributions from lower precedence. E.g. if a contributor with precedence 1000 contributes a function named "max", that will override Hibernate's standard function of that name.

      Returns:
      the ordinal for this FunctionContributor