Search in sources :

Example 6 with CommonFunctionFactory

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

the class AbstractHANADialect method initializeFunctionRegistry.

@Override
public void initializeFunctionRegistry(QueryEngine queryEngine) {
    super.initializeFunctionRegistry(queryEngine);
    final TypeConfiguration typeConfiguration = queryEngine.getTypeConfiguration();
    queryEngine.getSqmFunctionRegistry().registerBinaryTernaryPattern("locate", typeConfiguration.getBasicTypeRegistry().resolve(StandardBasicTypes.INTEGER), "locate(?2,?1)", "locate(?2,?1,?3)", FunctionParameterType.STRING, FunctionParameterType.STRING, FunctionParameterType.INTEGER, typeConfiguration).setArgumentListSignature("(pattern, string[, start])");
    CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
    functionFactory.ceiling_ceil();
    functionFactory.concat_pipeOperator();
    functionFactory.trim2();
    functionFactory.cot();
    functionFactory.cosh();
    functionFactory.sinh();
    functionFactory.tanh();
    functionFactory.log10_log();
    functionFactory.bitand();
    functionFactory.hourMinuteSecond();
    functionFactory.yearMonthDay();
    functionFactory.dayofweekmonthyear();
    functionFactory.weekQuarter();
    functionFactory.daynameMonthname();
    functionFactory.lastDay();
    functionFactory.characterLength_length(SqlAstNodeRenderingMode.DEFAULT);
    functionFactory.ascii();
    functionFactory.chr_char();
    functionFactory.addYearsMonthsDaysHoursMinutesSeconds();
    functionFactory.daysBetween();
    functionFactory.secondsBetween();
    functionFactory.format_toVarchar();
    functionFactory.currentUtcdatetimetimestamp();
    functionFactory.everyAny_minMaxCase();
    functionFactory.bitLength_pattern("length(to_binary(?1))*8");
    functionFactory.windowFunctions();
    functionFactory.listagg_stringAgg("varchar");
    functionFactory.inverseDistributionOrderedSetAggregates();
    functionFactory.hypotheticalOrderedSetAggregates_windowEmulation();
    queryEngine.getSqmFunctionRegistry().register("timestampadd", new IntegralTimestampaddFunction(this, typeConfiguration));
}
Also used : IntegralTimestampaddFunction(org.hibernate.dialect.function.IntegralTimestampaddFunction) CommonFunctionFactory(org.hibernate.dialect.function.CommonFunctionFactory) TypeConfiguration(org.hibernate.type.spi.TypeConfiguration)

Example 7 with CommonFunctionFactory

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

the class MySQLDialect method initializeFunctionRegistry.

// @Override
// public int getDefaultDecimalPrecision() {
// //this is the maximum, but I guess it's too high
// return 65;
// }
@Override
public void initializeFunctionRegistry(QueryEngine queryEngine) {
    super.initializeFunctionRegistry(queryEngine);
    CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
    functionFactory.soundex();
    functionFactory.radians();
    functionFactory.degrees();
    functionFactory.cot();
    functionFactory.log();
    functionFactory.log2();
    functionFactory.log10();
    functionFactory.pi();
    functionFactory.trim2();
    functionFactory.octetLength();
    functionFactory.reverse();
    functionFactory.space();
    functionFactory.repeat();
    functionFactory.pad_space();
    functionFactory.md5();
    functionFactory.yearMonthDay();
    functionFactory.hourMinuteSecond();
    functionFactory.dayofweekmonthyear();
    functionFactory.weekQuarter();
    functionFactory.daynameMonthname();
    functionFactory.lastDay();
    functionFactory.date();
    functionFactory.timestamp();
    time(queryEngine);
    functionFactory.utcDateTimeTimestamp();
    functionFactory.rand();
    functionFactory.crc32();
    functionFactory.sha1();
    functionFactory.sha2();
    functionFactory.sha();
    functionFactory.bitLength();
    functionFactory.octetLength();
    functionFactory.ascii();
    functionFactory.chr_char();
    functionFactory.instr();
    functionFactory.substr();
    // also natively supports ANSI-style substring()
    functionFactory.position();
    functionFactory.nowCurdateCurtime();
    functionFactory.truncate();
    functionFactory.insert();
    functionFactory.bitandorxornot_operator();
    functionFactory.bitAndOr();
    functionFactory.stddev();
    functionFactory.stddevPopSamp();
    functionFactory.variance();
    functionFactory.varPopSamp();
    functionFactory.datediff();
    functionFactory.adddateSubdateAddtimeSubtime();
    functionFactory.format_dateFormat();
    functionFactory.makedateMaketime();
    if (getMySQLVersion().isBefore(5, 7)) {
        functionFactory.sysdateParens();
    } else {
        // MySQL timestamp type defaults to precision 0 (seconds) but
        // we want the standard default precision of 6 (microseconds)
        functionFactory.sysdateExplicitMicros();
        if (getMySQLVersion().isSameOrAfter(8, 2)) {
            functionFactory.windowFunctions();
            if (getMySQLVersion().isSameOrAfter(8, 11)) {
                functionFactory.hypotheticalOrderedSetAggregates_windowEmulation();
            }
        }
    }
    functionFactory.listagg_groupConcat();
}
Also used : CommonFunctionFactory(org.hibernate.dialect.function.CommonFunctionFactory)

Example 8 with CommonFunctionFactory

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

the class OracleDialect method initializeFunctionRegistry.

@Override
public void initializeFunctionRegistry(QueryEngine queryEngine) {
    super.initializeFunctionRegistry(queryEngine);
    final TypeConfiguration typeConfiguration = queryEngine.getTypeConfiguration();
    CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
    functionFactory.cosh();
    functionFactory.sinh();
    functionFactory.tanh();
    functionFactory.trunc();
    functionFactory.log();
    functionFactory.log10_log();
    functionFactory.soundex();
    functionFactory.trim2();
    functionFactory.initcap();
    functionFactory.instr();
    functionFactory.substr();
    functionFactory.substring_substr();
    functionFactory.leftRight_substr();
    functionFactory.translate();
    functionFactory.bitand();
    functionFactory.lastDay();
    functionFactory.toCharNumberDateTimestamp();
    functionFactory.ceiling_ceil();
    functionFactory.concat_pipeOperator();
    functionFactory.rownumRowid();
    functionFactory.sysdate();
    functionFactory.systimestamp();
    functionFactory.characterLength_length(SqlAstNodeRenderingMode.DEFAULT);
    functionFactory.addMonths();
    functionFactory.monthsBetween();
    functionFactory.everyAny_minMaxCase();
    functionFactory.median();
    functionFactory.stddev();
    functionFactory.stddevPopSamp();
    functionFactory.variance();
    functionFactory.varPopSamp();
    functionFactory.covarPopSamp();
    functionFactory.corr();
    functionFactory.regrLinearRegressionAggregates();
    functionFactory.bitLength_pattern("vsize(?1)*8");
    if (getVersion().isBefore(9)) {
        queryEngine.getSqmFunctionRegistry().register("coalesce", new NvlCoalesceEmulation());
    } else {
        // Oracle has had coalesce() since 9.0.1
        functionFactory.coalesce();
    }
    queryEngine.getSqmFunctionRegistry().registerBinaryTernaryPattern("locate", typeConfiguration.getBasicTypeRegistry().resolve(StandardBasicTypes.INTEGER), "instr(?2,?1)", "instr(?2,?1,?3)", FunctionParameterType.STRING, FunctionParameterType.STRING, FunctionParameterType.INTEGER, typeConfiguration).setArgumentListSignature("(pattern, string[, start])");
    // The within group clause became optional in 18
    if (getVersion().isSameOrAfter(18)) {
        functionFactory.listagg(null);
    } else {
        functionFactory.listagg("within group (order by rownum)");
    }
    functionFactory.windowFunctions();
    functionFactory.hypotheticalOrderedSetAggregates();
    functionFactory.inverseDistributionOrderedSetAggregates();
    // Oracle has a regular aggregate function named stats_mode
    queryEngine.getSqmFunctionRegistry().register("mode", new ModeStatsModeEmulation(typeConfiguration));
}
Also used : ModeStatsModeEmulation(org.hibernate.dialect.function.ModeStatsModeEmulation) NvlCoalesceEmulation(org.hibernate.dialect.function.NvlCoalesceEmulation) CommonFunctionFactory(org.hibernate.dialect.function.CommonFunctionFactory) TypeConfiguration(org.hibernate.type.spi.TypeConfiguration)

Example 9 with CommonFunctionFactory

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

the class PostgreSQLDialect method initializeFunctionRegistry.

@Override
public void initializeFunctionRegistry(QueryEngine queryEngine) {
    super.initializeFunctionRegistry(queryEngine);
    CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
    // Postgres round(x,n) does not accept double
    functionFactory.round_floor();
    functionFactory.cot();
    functionFactory.radians();
    functionFactory.degrees();
    functionFactory.trunc();
    functionFactory.log();
    if (getVersion().isSameOrAfter(12)) {
        functionFactory.log10();
    } else {
        queryEngine.getSqmFunctionRegistry().registerAlternateKey("log10", "log");
    }
    functionFactory.cbrt();
    functionFactory.trim2();
    functionFactory.octetLength();
    functionFactory.repeat();
    functionFactory.md5();
    functionFactory.initcap();
    functionFactory.substr();
    functionFactory.substring_substr();
    // also natively supports ANSI-style substring()
    functionFactory.translate();
    functionFactory.toCharNumberDateTimestamp();
    functionFactory.concat_pipeOperator();
    functionFactory.localtimeLocaltimestamp();
    functionFactory.dateTrunc();
    functionFactory.bitLength();
    functionFactory.octetLength();
    functionFactory.ascii();
    functionFactory.char_chr();
    functionFactory.position();
    functionFactory.bitandorxornot_operator();
    functionFactory.bitAndOr();
    functionFactory.everyAny_boolAndOr();
    functionFactory.median_percentileCont(false);
    functionFactory.stddev();
    functionFactory.stddevPopSamp();
    functionFactory.variance();
    functionFactory.varPopSamp();
    functionFactory.covarPopSamp();
    functionFactory.corr();
    functionFactory.regrLinearRegressionAggregates();
    functionFactory.insert_overlay();
    functionFactory.overlay();
    // was introduced in Postgres 9 apparently
    functionFactory.soundex();
    functionFactory.locate_positionSubstring();
    functionFactory.windowFunctions();
    functionFactory.listagg_stringAgg("varchar");
    if (getVersion().isSameOrAfter(9, 4)) {
        functionFactory.makeDateTimeTimestamp();
        // Note that PostgreSQL doesn't support the OVER clause for ordered set-aggregate functions
        functionFactory.inverseDistributionOrderedSetAggregates();
        functionFactory.hypotheticalOrderedSetAggregates();
    }
}
Also used : CommonFunctionFactory(org.hibernate.dialect.function.CommonFunctionFactory)

Example 10 with CommonFunctionFactory

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

the class DB2iDialect method initializeFunctionRegistry.

@Override
public void initializeFunctionRegistry(QueryEngine queryEngine) {
    super.initializeFunctionRegistry(queryEngine);
    if (getVersion().isSameOrAfter(7, 2)) {
        CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
        functionFactory.listagg(null);
        functionFactory.inverseDistributionOrderedSetAggregates();
        functionFactory.hypotheticalOrderedSetAggregates_windowEmulation();
    }
}
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