Search in sources :

Example 1 with DB2FormatEmulation

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

the class DB2Dialect method initializeFunctionRegistry.

@Override
public void initializeFunctionRegistry(QueryEngine queryEngine) {
    super.initializeFunctionRegistry(queryEngine);
    CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
    // AVG by default uses the input type, so we possibly need to cast the argument type, hence a special function
    functionFactory.avg_castingNonDoubleArguments(this, SqlAstNodeRenderingMode.DEFAULT);
    functionFactory.cot();
    functionFactory.degrees();
    functionFactory.log();
    functionFactory.log10();
    functionFactory.radians();
    functionFactory.rand();
    functionFactory.soundex();
    functionFactory.trim2();
    functionFactory.space();
    functionFactory.repeat();
    queryEngine.getSqmFunctionRegistry().namedDescriptorBuilder("substr").setInvariantType(queryEngine.getTypeConfiguration().getBasicTypeRegistry().resolve(StandardBasicTypes.STRING)).setArgumentCountBetween(2, 4).setParameterTypes(FunctionParameterType.STRING, FunctionParameterType.INTEGER, FunctionParameterType.INTEGER, FunctionParameterType.ANY).setArgumentListSignature("(STRING string, INTEGER start[, INTEGER length[, units]])").register();
    queryEngine.getSqmFunctionRegistry().namedDescriptorBuilder("substring").setInvariantType(queryEngine.getTypeConfiguration().getBasicTypeRegistry().resolve(StandardBasicTypes.STRING)).setArgumentCountBetween(2, 4).setParameterTypes(FunctionParameterType.STRING, FunctionParameterType.INTEGER, FunctionParameterType.INTEGER, FunctionParameterType.ANY).setArgumentListSignature("(STRING string{ INTEGER from|,} start[{ INTEGER for|,} length[, units]])").register();
    functionFactory.translate();
    functionFactory.bitand();
    functionFactory.bitor();
    functionFactory.bitxor();
    functionFactory.bitnot();
    functionFactory.yearMonthDay();
    functionFactory.hourMinuteSecond();
    functionFactory.dayofweekmonthyear();
    functionFactory.weekQuarter();
    functionFactory.daynameMonthname();
    functionFactory.lastDay();
    functionFactory.toCharNumberDateTimestamp();
    functionFactory.dateTimeTimestamp();
    functionFactory.concat_pipeOperator();
    functionFactory.octetLength();
    functionFactory.ascii();
    functionFactory.char_chr();
    functionFactory.position();
    functionFactory.trunc();
    functionFactory.truncate();
    functionFactory.insert();
    functionFactory.overlayCharacterLength_overlay();
    functionFactory.median();
    functionFactory.stddev();
    functionFactory.stddevPopSamp();
    functionFactory.regrLinearRegressionAggregates();
    functionFactory.variance();
    functionFactory.stdevVarianceSamp();
    functionFactory.addYearsMonthsDaysHoursMinutesSeconds();
    functionFactory.yearsMonthsDaysHoursMinutesSecondsBetween();
    functionFactory.dateTrunc();
    functionFactory.bitLength_pattern("length(?1)*8");
    // DB2 wants parameter operands to be casted to allow lengths bigger than 255
    queryEngine.getSqmFunctionRegistry().register("concat", new CastingConcatFunction(this, "||", true, SqlAstNodeRenderingMode.NO_PLAIN_PARAMETER, queryEngine.getTypeConfiguration()));
    // For the count distinct emulation distinct
    queryEngine.getSqmFunctionRegistry().register("count", new CountFunction(this, queryEngine.getTypeConfiguration(), SqlAstNodeRenderingMode.DEFAULT, "||", getCastTypeName(queryEngine.getTypeConfiguration().getBasicTypeRegistry().resolve(StandardBasicTypes.STRING), null, null, null), true));
    queryEngine.getSqmFunctionRegistry().register("format", new DB2FormatEmulation(queryEngine.getTypeConfiguration()));
    queryEngine.getSqmFunctionRegistry().namedDescriptorBuilder("posstr").setInvariantType(queryEngine.getTypeConfiguration().getBasicTypeRegistry().resolve(StandardBasicTypes.INTEGER)).setExactArgumentCount(2).setParameterTypes(FunctionParameterType.STRING, FunctionParameterType.STRING).setArgumentListSignature("(STRING string, STRING pattern)").register();
    functionFactory.windowFunctions();
    if (getDB2Version().isSameOrAfter(9, 5)) {
        functionFactory.listagg(null);
        if (getDB2Version().isSameOrAfter(11, 1)) {
            functionFactory.inverseDistributionOrderedSetAggregates();
            functionFactory.hypotheticalOrderedSetAggregates_windowEmulation();
        }
    }
}
Also used : CountFunction(org.hibernate.dialect.function.CountFunction) CommonFunctionFactory(org.hibernate.dialect.function.CommonFunctionFactory) DB2FormatEmulation(org.hibernate.dialect.function.DB2FormatEmulation) CastingConcatFunction(org.hibernate.dialect.function.CastingConcatFunction)

Aggregations

CastingConcatFunction (org.hibernate.dialect.function.CastingConcatFunction)1 CommonFunctionFactory (org.hibernate.dialect.function.CommonFunctionFactory)1 CountFunction (org.hibernate.dialect.function.CountFunction)1 DB2FormatEmulation (org.hibernate.dialect.function.DB2FormatEmulation)1