Search in sources :

Example 6 with SqmFunctionRegistry

use of org.hibernate.query.sqm.function.SqmFunctionRegistry in project hibernate-orm by hibernate.

the class MariaDBDialectContributor method contributeFunctions.

@Override
public void contributeFunctions(FunctionContributions functionContributions) {
    HSMessageLogger.LOGGER.functionContributions(this.getClass().getCanonicalName());
    final KeyedSqmFunctionDescriptors mariaDbFunctions = new MariaDBSqmFunctionDescriptors(functionContributions);
    final SqmFunctionRegistry functionRegistry = functionContributions.getFunctionRegistry();
    mariaDbFunctions.asMap().forEach((key, desc) -> {
        functionRegistry.register(key.getName(), desc);
        key.getAltName().ifPresent(altName -> functionRegistry.registerAlternateKey(altName, key.getName()));
    });
}
Also used : KeyedSqmFunctionDescriptors(org.hibernate.spatial.KeyedSqmFunctionDescriptors) SqmFunctionRegistry(org.hibernate.query.sqm.function.SqmFunctionRegistry)

Example 7 with SqmFunctionRegistry

use of org.hibernate.query.sqm.function.SqmFunctionRegistry in project hibernate-orm by hibernate.

the class RequiresFunctionExtension method evaluateExecutionCondition.

@Override
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
    Optional<Object> testInstance = context.getTestInstance();
    if (!testInstance.isPresent()) {
        return ENABLED;
    }
    ExtensionContext.Store store = JUnitHelper.locateExtensionStore(SessionFactoryExtension.class, context, testInstance.get());
    final SessionFactoryScope existing = (SessionFactoryScope) store.get(SessionFactoryScope.class.getName());
    if (existing == null) {
        return ConditionEvaluationResult.enabled("");
    }
    final Optional<RequiresFunction> requiresFunctions = TestingUtil.findEffectiveAnnotation(context, RequiresFunction.class);
    if (requiresFunctions.isPresent()) {
        String functionKey = requiresFunctions.get().key();
        SqmFunctionRegistry functionRegistry = existing.getSessionFactory().getQueryEngine().getSqmFunctionRegistry();
        if (functionRegistry.findFunctionDescriptor(functionKey) == null) {
            return ConditionEvaluationResult.disabled(String.format(Locale.ROOT, "Failed: Required function %s is not available", functionKey));
        }
        return ConditionEvaluationResult.enabled("Required function is supported");
    }
    return ENABLED;
}
Also used : ExtensionContext(org.junit.jupiter.api.extension.ExtensionContext) SessionFactoryScope(org.hibernate.testing.orm.junit.SessionFactoryScope) SqmFunctionRegistry(org.hibernate.query.sqm.function.SqmFunctionRegistry)

Example 8 with SqmFunctionRegistry

use of org.hibernate.query.sqm.function.SqmFunctionRegistry in project hibernate-orm by hibernate.

the class MySQLDialectContributor method contributeFunctions.

@Override
public void contributeFunctions(FunctionContributions functionContributions) {
    HSMessageLogger.LOGGER.functionContributions(this.getClass().getCanonicalName());
    final KeyedSqmFunctionDescriptors mysqlFunctions = new MySqlSqmFunctionDescriptors(functionContributions);
    final SqmFunctionRegistry functionRegistry = functionContributions.getFunctionRegistry();
    mysqlFunctions.asMap().forEach((key, desc) -> {
        functionRegistry.register(key.getName(), desc);
        key.getAltName().ifPresent(altName -> functionRegistry.registerAlternateKey(altName, key.getName()));
    });
}
Also used : KeyedSqmFunctionDescriptors(org.hibernate.spatial.KeyedSqmFunctionDescriptors) SqmFunctionRegistry(org.hibernate.query.sqm.function.SqmFunctionRegistry)

Example 9 with SqmFunctionRegistry

use of org.hibernate.query.sqm.function.SqmFunctionRegistry in project hibernate-orm by hibernate.

the class OracleDialectContributor method contributeFunctions.

@Override
public void contributeFunctions(FunctionContributions functionContributions) {
    HSMessageLogger.LOGGER.functionContributions(this.getClass().getCanonicalName());
    KeyedSqmFunctionDescriptors functionDescriptors;
    if (useSTGeometry) {
        functionDescriptors = new OracleSQLMMFunctionDescriptors(functionContributions);
    } else {
        functionDescriptors = new OracleSDOFunctionDescriptors(functionContributions);
    }
    SqmFunctionRegistry functionRegistry = functionContributions.getFunctionRegistry();
    functionDescriptors.asMap().forEach((key, funcDescr) -> {
        functionRegistry.register(key.getName(), funcDescr);
        key.getAltName().ifPresent(altName -> functionRegistry.register(altName, funcDescr));
    });
}
Also used : KeyedSqmFunctionDescriptors(org.hibernate.spatial.KeyedSqmFunctionDescriptors) SqmFunctionRegistry(org.hibernate.query.sqm.function.SqmFunctionRegistry)

Example 10 with SqmFunctionRegistry

use of org.hibernate.query.sqm.function.SqmFunctionRegistry in project hibernate-orm by hibernate.

the class PostgisDialectContributor method contributeFunctions.

@Override
public void contributeFunctions(FunctionContributions functionContributions) {
    HSMessageLogger.LOGGER.functionContributions(this.getClass().getCanonicalName());
    final PostgisSqmFunctionDescriptors postgisFunctions = new PostgisSqmFunctionDescriptors(functionContributions);
    final SqmFunctionRegistry functionRegistry = functionContributions.getFunctionRegistry();
    postgisFunctions.asMap().forEach((key, desc) -> {
        functionRegistry.register(key.getName(), desc);
        key.getAltName().ifPresent(altName -> functionRegistry.registerAlternateKey(altName, key.getName()));
    });
}
Also used : SqmFunctionRegistry(org.hibernate.query.sqm.function.SqmFunctionRegistry)

Aggregations

SqmFunctionRegistry (org.hibernate.query.sqm.function.SqmFunctionRegistry)10 KeyedSqmFunctionDescriptors (org.hibernate.spatial.KeyedSqmFunctionDescriptors)4 Dialect (org.hibernate.dialect.Dialect)1 CommonFunctionFactory (org.hibernate.dialect.function.CommonFunctionFactory)1 NativeQueryInterpreter (org.hibernate.engine.query.spi.NativeQueryInterpreter)1 HqlTranslator (org.hibernate.query.hql.HqlTranslator)1 StandardHqlTranslator (org.hibernate.query.hql.internal.StandardHqlTranslator)1 SqmCreationOptions (org.hibernate.query.hql.spi.SqmCreationOptions)1 SqmFunctionDescriptor (org.hibernate.query.sqm.function.SqmFunctionDescriptor)1 SqmCreationOptionsStandard (org.hibernate.query.sqm.internal.SqmCreationOptionsStandard)1 SqmTranslatorFactory (org.hibernate.query.sqm.sql.SqmTranslatorFactory)1 StandardSqmTranslatorFactory (org.hibernate.query.sqm.sql.StandardSqmTranslatorFactory)1 PostgisSqmFunctionDescriptors (org.hibernate.spatial.dialect.postgis.PostgisSqmFunctionDescriptors)1 SessionFactoryScope (org.hibernate.testing.orm.junit.SessionFactoryScope)1 BasicTypeRegistry (org.hibernate.type.BasicTypeRegistry)1 ExtensionContext (org.junit.jupiter.api.extension.ExtensionContext)1