try to make var_xxx() and sdtev_xxx() more portable
This commit is contained in:
parent
477f1e7af6
commit
f5a5990d03
|
@ -1795,7 +1795,7 @@ public class HQLTest extends BaseEntityManagerFunctionalTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
@RequiresDialect({MySQLDialect.class, PostgreSQLDialect.class, H2Dialect.class, DerbyDialect.class, OracleDialect.class})
|
||||
// @RequiresDialect({MySQLDialect.class, PostgreSQLDialect.class, H2Dialect.class, DerbyDialect.class, OracleDialect.class})
|
||||
public void test_var_function_example() {
|
||||
doInJPA(this::entityManagerFactory, entityManager -> {
|
||||
//tag::hql-native-function-example[]
|
||||
|
|
|
@ -277,9 +277,10 @@ public class DB2LegacyDialect extends Dialect {
|
|||
functionFactory.median();
|
||||
functionFactory.stddev();
|
||||
functionFactory.stddevPopSamp();
|
||||
functionFactory.varPopSamp();
|
||||
functionFactory.regrLinearRegressionAggregates();
|
||||
functionFactory.variance();
|
||||
functionFactory.stdevVarianceSamp();
|
||||
functionFactory.varianceSamp();
|
||||
functionFactory.addYearsMonthsDaysHoursMinutesSeconds();
|
||||
functionFactory.yearsMonthsDaysHoursMinutesSecondsBetween();
|
||||
functionFactory.dateTrunc();
|
||||
|
|
|
@ -259,9 +259,10 @@ public class DB2Dialect extends Dialect {
|
|||
functionFactory.median();
|
||||
functionFactory.stddev();
|
||||
functionFactory.stddevPopSamp();
|
||||
functionFactory.varPopSamp();
|
||||
functionFactory.regrLinearRegressionAggregates();
|
||||
functionFactory.variance();
|
||||
functionFactory.stdevVarianceSamp();
|
||||
functionFactory.varianceSamp();
|
||||
functionFactory.addYearsMonthsDaysHoursMinutesSeconds();
|
||||
functionFactory.yearsMonthsDaysHoursMinutesSecondsBetween();
|
||||
functionFactory.dateTrunc();
|
||||
|
|
|
@ -208,6 +208,13 @@ public class SybaseDialect extends AbstractTransactSQLDialect {
|
|||
|
||||
CommonFunctionFactory functionFactory = new CommonFunctionFactory(queryEngine);
|
||||
|
||||
functionFactory.stddev();
|
||||
functionFactory.variance();
|
||||
functionFactory.stddevPopSamp_stdevp();
|
||||
functionFactory.varPopSamp_varp();
|
||||
functionFactory.stddevPopSamp();
|
||||
functionFactory.varPopSamp();
|
||||
|
||||
// For SQL-Server we need to cast certain arguments to varchar(16384) to be able to concat them
|
||||
queryEngine.getSqmFunctionRegistry().register(
|
||||
"count",
|
||||
|
|
|
@ -419,12 +419,7 @@ public class CommonFunctionFactory {
|
|||
/**
|
||||
* DB2
|
||||
*/
|
||||
public void stdevVarianceSamp() {
|
||||
functionRegistry.namedAggregateDescriptorBuilder( "stddev_samp" )
|
||||
.setInvariantType(doubleType)
|
||||
.setExactArgumentCount( 1 )
|
||||
.setParameterTypes(NUMERIC)
|
||||
.register();
|
||||
public void varianceSamp() {
|
||||
functionRegistry.namedAggregateDescriptorBuilder( "variance_samp" )
|
||||
.setInvariantType(doubleType)
|
||||
.setExactArgumentCount( 1 )
|
||||
|
|
|
@ -926,6 +926,16 @@ public class FunctionTests {
|
|||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStatisticalFunctions(SessionFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
session -> {
|
||||
session.createQuery("select var_samp(e.theDouble), var_pop(abs(e.theDouble)), stddev_samp(e.theDouble), stddev_pop(e.theDouble) from EntityOfBasics e")
|
||||
.list();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCurrentDateTimeFunctions(SessionFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
|
|
Loading…
Reference in New Issue