Search in sources :

Example 1 with CommonFunctionFactory

use of org.hibernate.dialect.function.CommonFunctionFactory in project hibernate-orm by hibernate.

the class IngresDialect method initializeFunctionRegistry.

@Override
public void initializeFunctionRegistry(QueryEngine queryEngine) {
    super.initializeFunctionRegistry(queryEngine);
    final BasicTypeRegistry basicTypeRegistry = queryEngine.getTypeConfiguration().getBasicTypeRegistry();
    final BasicType<String> stringType = basicTypeRegistry.resolve(StandardBasicTypes.STRING);
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // Common functions
    CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
    functionFactory.log();
    functionFactory.rand();
    functionFactory.soundex();
    functionFactory.octetLength();
    functionFactory.repeat();
    functionFactory.trim2();
    functionFactory.trunc();
    functionFactory.truncate();
    functionFactory.initcap();
    functionFactory.yearMonthDay();
    functionFactory.hourMinuteSecond();
    functionFactory.dayofweekmonthyear();
    functionFactory.weekQuarter();
    functionFactory.lastDay();
    functionFactory.concat_pipeOperator();
    functionFactory.substr();
    functionFactory.monthsBetween();
    functionFactory.substring_substr();
    // also natively supports ANSI-style substring()
    functionFactory.ascii();
    functionFactory.char_chr();
    functionFactory.sysdate();
    functionFactory.position();
    functionFactory.format_dateFormat();
    functionFactory.dateTrunc();
    functionFactory.bitLength_pattern("octet_length(hex(?1))*4");
    final BasicType<Integer> integerType = queryEngine.getTypeConfiguration().getBasicTypeRegistry().resolve(StandardBasicTypes.INTEGER);
    queryEngine.getSqmFunctionRegistry().registerBinaryTernaryPattern("locate", integerType, "position(?1 in ?2)", "(position(?1 in substring(?2 from ?3))+(?3)-1)", STRING, STRING, INTEGER, queryEngine.getTypeConfiguration()).setArgumentListSignature("(pattern, string[, start])");
    queryEngine.getSqmFunctionRegistry().registerPattern("extract", "date_part('?1',?2)", integerType);
    functionFactory.bitandorxornot_bitAndOrXorNot();
    queryEngine.getSqmFunctionRegistry().namedDescriptorBuilder("squeeze").setExactArgumentCount(1).setInvariantType(stringType).register();
    // No idea since when this is supported
    functionFactory.windowFunctions();
    functionFactory.listagg(null);
    functionFactory.inverseDistributionOrderedSetAggregates();
    functionFactory.hypotheticalOrderedSetAggregates();
}
Also used : CommonFunctionFactory(org.hibernate.dialect.function.CommonFunctionFactory) BasicTypeRegistry(org.hibernate.type.BasicTypeRegistry)

Example 2 with CommonFunctionFactory

use of org.hibernate.dialect.function.CommonFunctionFactory in project hibernate-orm by hibernate.

the class InformixDialect method initializeFunctionRegistry.

@Override
public void initializeFunctionRegistry(QueryEngine queryEngine) {
    super.initializeFunctionRegistry(queryEngine);
    CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
    functionFactory.instr();
    functionFactory.substr();
    functionFactory.substring_substr();
    // also natively supports ANSI-style substring()
    functionFactory.trunc();
    functionFactory.trim2();
    functionFactory.space();
    functionFactory.reverse();
    functionFactory.octetLength();
    functionFactory.degrees();
    functionFactory.radians();
    functionFactory.sinh();
    functionFactory.tanh();
    functionFactory.cosh();
    functionFactory.moreHyperbolic();
    functionFactory.log10();
    functionFactory.initcap();
    functionFactory.yearMonthDay();
    functionFactory.ceiling_ceil();
    functionFactory.concat_pipeOperator();
    functionFactory.ascii();
    functionFactory.char_chr();
    functionFactory.addMonths();
    functionFactory.monthsBetween();
    functionFactory.stddev();
    functionFactory.variance();
    functionFactory.locate_positionSubstring();
    // coalesce() and nullif() both supported since Informix 12
    queryEngine.getSqmFunctionRegistry().register("least", new CaseLeastGreatestEmulation(true));
    queryEngine.getSqmFunctionRegistry().register("greatest", new CaseLeastGreatestEmulation(false));
    if (supportsWindowFunctions()) {
        functionFactory.windowFunctions();
    }
}
Also used : CommonFunctionFactory(org.hibernate.dialect.function.CommonFunctionFactory) CaseLeastGreatestEmulation(org.hibernate.dialect.function.CaseLeastGreatestEmulation)

Example 3 with CommonFunctionFactory

use of org.hibernate.dialect.function.CommonFunctionFactory in project hibernate-orm by hibernate.

the class MaxDBDialect method initializeFunctionRegistry.

@Override
public void initializeFunctionRegistry(QueryEngine queryEngine) {
    super.initializeFunctionRegistry(queryEngine);
    CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
    functionFactory.log();
    functionFactory.pi();
    functionFactory.cot();
    functionFactory.cosh();
    functionFactory.sinh();
    functionFactory.tanh();
    functionFactory.radians();
    functionFactory.degrees();
    functionFactory.trunc();
    functionFactory.trim2();
    functionFactory.substr();
    functionFactory.substring_substr();
    functionFactory.translate();
    functionFactory.initcap();
    functionFactory.soundex();
    functionFactory.yearMonthDay();
    functionFactory.hourMinuteSecond();
    functionFactory.dayofweekmonthyear();
    functionFactory.daynameMonthname();
    functionFactory.dateTimeTimestamp();
    functionFactory.ceiling_ceil();
    functionFactory.week_weekofyear();
    functionFactory.concat_pipeOperator();
    functionFactory.coalesce_value();
    // since lpad/rpad are not actually useful padding
    // functions, map them to lfill/rfill
    functionFactory.pad_fill();
    functionFactory.datediff();
    functionFactory.adddateSubdateAddtimeSubtime();
    functionFactory.addMonths();
    final BasicType<Integer> integerType = queryEngine.getTypeConfiguration().getBasicTypeRegistry().resolve(StandardBasicTypes.INTEGER);
    queryEngine.getSqmFunctionRegistry().registerPattern("extract", "?1(?2)", integerType);
    queryEngine.getSqmFunctionRegistry().patternDescriptorBuilder("nullif", "case ?1 when ?2 then null else ?1 end").setExactArgumentCount(2).register();
    queryEngine.getSqmFunctionRegistry().namedDescriptorBuilder("index").setInvariantType(integerType).setArgumentCountBetween(2, 4).register();
    queryEngine.getSqmFunctionRegistry().registerBinaryTernaryPattern("locate", integerType, "index(?2,?1)", "index(?2,?1,?3)", STRING, STRING, INTEGER, queryEngine.getTypeConfiguration()).setArgumentListSignature("(pattern, string[, start])");
}
Also used : CommonFunctionFactory(org.hibernate.dialect.function.CommonFunctionFactory)

Example 4 with CommonFunctionFactory

use of org.hibernate.dialect.function.CommonFunctionFactory 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");
}
Also used : CommonFunctionFactory(org.hibernate.dialect.function.CommonFunctionFactory) BasicTypeRegistry(org.hibernate.type.BasicTypeRegistry) SqmFunctionRegistry(org.hibernate.query.sqm.function.SqmFunctionRegistry)

Example 5 with CommonFunctionFactory

use of org.hibernate.dialect.function.CommonFunctionFactory in project hibernate-orm by hibernate.

the class SybaseAnywhereDialect method initializeFunctionRegistry.

@Override
public void initializeFunctionRegistry(QueryEngine queryEngine) {
    super.initializeFunctionRegistry(queryEngine);
    final CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
    functionFactory.listagg_list("varchar");
    if (getVersion().isSameOrAfter(12)) {
        functionFactory.windowFunctions();
    }
}
Also used : CommonFunctionFactory(org.hibernate.dialect.function.CommonFunctionFactory)

Aggregations

CommonFunctionFactory (org.hibernate.dialect.function.CommonFunctionFactory)30 BasicTypeRegistry (org.hibernate.type.BasicTypeRegistry)9 CountFunction (org.hibernate.dialect.function.CountFunction)4 Date (java.util.Date)3 CaseLeastGreatestEmulation (org.hibernate.dialect.function.CaseLeastGreatestEmulation)3 CastingConcatFunction (org.hibernate.dialect.function.CastingConcatFunction)3 TypeConfiguration (org.hibernate.type.spi.TypeConfiguration)3 InsertSubstringOverlayEmulation (org.hibernate.dialect.function.InsertSubstringOverlayEmulation)2 IntegralTimestampaddFunction (org.hibernate.dialect.function.IntegralTimestampaddFunction)2 DateTimeUtils.appendAsDate (org.hibernate.type.descriptor.DateTimeUtils.appendAsDate)2 Instant (java.time.Instant)1 LocalDate (java.time.LocalDate)1 LocalDateTime (java.time.LocalDateTime)1 LocalTime (java.time.LocalTime)1 OffsetDateTime (java.time.OffsetDateTime)1 CastFunction (org.hibernate.dialect.function.CastFunction)1 CastStrEmulation (org.hibernate.dialect.function.CastStrEmulation)1 CoalesceIfnullEmulation (org.hibernate.dialect.function.CoalesceIfnullEmulation)1 CurrentFunction (org.hibernate.dialect.function.CurrentFunction)1 DB2FormatEmulation (org.hibernate.dialect.function.DB2FormatEmulation)1