use of org.hibernate.query.sqm.function.SqmFunctionRegistry in project hibernate-orm by hibernate.
the class FirebirdDialect method initializeFunctionRegistry.
@Override
public void initializeFunctionRegistry(QueryEngine queryEngine) {
super.initializeFunctionRegistry(queryEngine);
final BasicTypeRegistry basicTypeRegistry = queryEngine.getTypeConfiguration().getBasicTypeRegistry();
final BasicType<byte[]> byteArrayType = basicTypeRegistry.resolve(StandardBasicTypes.BINARY);
final BasicType<Integer> integerType = basicTypeRegistry.resolve(StandardBasicTypes.INTEGER);
final BasicType<Short> shortType = basicTypeRegistry.resolve(StandardBasicTypes.SHORT);
final BasicType<Double> doubleType = basicTypeRegistry.resolve(StandardBasicTypes.DOUBLE);
final BasicType<Character> characterType = basicTypeRegistry.resolve(StandardBasicTypes.CHARACTER);
CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
functionFactory.concat_pipeOperator();
functionFactory.cot();
functionFactory.cosh();
functionFactory.sinh();
functionFactory.tanh();
if (getVersion().isSameOrAfter(3, 0)) {
functionFactory.moreHyperbolic();
functionFactory.stddevPopSamp();
functionFactory.varPopSamp();
functionFactory.covarPopSamp();
functionFactory.corr();
functionFactory.regrLinearRegressionAggregates();
}
functionFactory.log();
functionFactory.log10();
functionFactory.pi();
functionFactory.rand();
functionFactory.sinh();
functionFactory.tanh();
functionFactory.cosh();
functionFactory.trunc();
functionFactory.octetLength();
functionFactory.bitLength();
functionFactory.substringFromFor();
functionFactory.overlay();
functionFactory.position();
functionFactory.reverse();
functionFactory.bitandorxornot_binAndOrXorNot();
functionFactory.leastGreatest_minMaxValue();
SqmFunctionRegistry functionRegistry = queryEngine.getSqmFunctionRegistry();
functionRegistry.registerBinaryTernaryPattern("locate", integerType, "position(?1 in ?2)", "position(?1,?2,?3)", STRING, STRING, INTEGER, queryEngine.getTypeConfiguration()).setArgumentListSignature("(pattern, string[, start])");
functionRegistry.namedDescriptorBuilder("ascii_val").setExactArgumentCount(1).setInvariantType(shortType).register();
functionRegistry.registerAlternateKey("ascii", "ascii_val");
functionRegistry.namedDescriptorBuilder("ascii_char").setExactArgumentCount(1).setInvariantType(characterType).register();
functionRegistry.registerAlternateKey("chr", "ascii_char");
functionRegistry.registerAlternateKey("char", "ascii_char");
functionRegistry.registerPattern("radians", "((?1)*pi()/180e0)", doubleType);
functionRegistry.registerPattern("degrees", "((?1)*180e0/pi())", doubleType);
if (getVersion().isSameOrAfter(3)) {
functionFactory.windowFunctions();
if (getVersion().isSameOrAfter(4, 0)) {
Arrays.asList("md5", "sha1", "sha256", "sha512").forEach(hash -> functionRegistry.registerPattern(hash, "crypt_hash(?1 using " + hash + ")", byteArrayType));
functionRegistry.registerAlternateKey("sha", "sha1");
functionRegistry.registerPattern("crc32", "hash(?1 using crc32)", integerType);
}
}
functionFactory.listagg_list("varchar");
}
use of org.hibernate.query.sqm.function.SqmFunctionRegistry in project hibernate-orm by hibernate.
the class QueryEngine method from.
public static QueryEngine from(SessionFactoryImplementor sessionFactory, MetadataImplementor metadata) {
final QueryEngineOptions queryEngineOptions = sessionFactory.getSessionFactoryOptions();
final SqmCreationOptions sqmCreationOptions = new SqmCreationOptionsStandard(sessionFactory);
final Dialect dialect = sessionFactory.getJdbcServices().getDialect();
final HqlTranslator hqlTranslator = resolveHqlTranslator(queryEngineOptions, dialect, sessionFactory, sqmCreationOptions);
final SqmTranslatorFactory sqmTranslatorFactory = resolveSqmTranslatorFactory(queryEngineOptions, dialect);
final SqmFunctionRegistry customSqmFunctionRegistry;
if (queryEngineOptions.getCustomSqmFunctionRegistry() == null) {
final Map<String, SqmFunctionDescriptor> customSqlFunctionMap = queryEngineOptions.getCustomSqlFunctionMap();
if (customSqlFunctionMap == null || customSqlFunctionMap.isEmpty()) {
customSqmFunctionRegistry = null;
} else {
customSqmFunctionRegistry = new SqmFunctionRegistry();
customSqlFunctionMap.forEach(customSqmFunctionRegistry::register);
}
} else {
customSqmFunctionRegistry = queryEngineOptions.getCustomSqmFunctionRegistry();
}
return new QueryEngine(sessionFactory.getUuid(), sessionFactory.getName(), sessionFactory.getSessionFactoryOptions().getJpaCompliance(), () -> sessionFactory.getRuntimeMetamodels().getJpaMetamodel(), sessionFactory.getSessionFactoryOptions().getCriteriaValueHandlingMode(), sessionFactory.getSessionFactoryOptions().getPreferredSqlTypeCodeForBoolean(), metadata.buildNamedQueryRepository(sessionFactory), hqlTranslator, sqmTranslatorFactory, sessionFactory.getServiceRegistry().getService(NativeQueryInterpreter.class), buildInterpretationCache(sessionFactory::getStatistics, sessionFactory.getProperties()), metadata.getTypeConfiguration(), dialect, customSqmFunctionRegistry, sessionFactory.getServiceRegistry());
}
use of org.hibernate.query.sqm.function.SqmFunctionRegistry in project hibernate-orm by hibernate.
the class SqlServerDialectContributor method contributeFunctions.
@Override
public void contributeFunctions(FunctionContributions functionContributions) {
HSMessageLogger.LOGGER.functionContributions(this.getClass().getCanonicalName());
final SqlServerSqmFunctionDescriptors functions = new SqlServerSqmFunctionDescriptors(functionContributions);
final SqmFunctionRegistry functionRegistry = functionContributions.getFunctionRegistry();
functions.asMap().forEach((key, desc) -> {
functionRegistry.register(key.getName(), desc);
key.getAltName().ifPresent(altName -> functionRegistry.registerAlternateKey(altName, key.getName()));
});
}
use of org.hibernate.query.sqm.function.SqmFunctionRegistry in project hibernate-orm by hibernate.
the class CockroachDbContributor 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) -> {
if (isUnsupported(key)) {
return;
}
functionRegistry.register(key.getName(), desc);
key.getAltName().ifPresent(altName -> functionRegistry.registerAlternateKey(altName, key.getName()));
});
}
use of org.hibernate.query.sqm.function.SqmFunctionRegistry in project hibernate-orm by hibernate.
the class H2GisDialectContributor method contributeFunctions.
@Override
public void contributeFunctions(FunctionContributions functionContributions) {
HSMessageLogger.LOGGER.functionContributions(this.getClass().getCanonicalName());
final KeyedSqmFunctionDescriptors functions = new H2SqmFunctionDescriptors(functionContributions);
final SqmFunctionRegistry functionRegistry = functionContributions.getFunctionRegistry();
functions.asMap().forEach((key, desc) -> {
functionRegistry.register(key.getName(), desc);
key.getAltName().ifPresent(altName -> functionRegistry.registerAlternateKey(altName, key.getName()));
});
}
Aggregations