mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-07 11:48:18 +00:00
try to make var_xxx() and sdtev_xxx() more portable
This commit is contained in:
parent
477f1e7af6
commit
f5a5990d03
@ -1795,7 +1795,7 @@ public void test_hql_current_timestamp_function_example() {
|
||||
}
|
||||
|
||||
@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 void initializeFunctionRegistry(QueryEngine queryEngine) {
|
||||
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 void initializeFunctionRegistry(QueryEngine queryEngine) {
|
||||
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 void initializeFunctionRegistry(QueryEngine queryEngine) {
|
||||
|
||||
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 void regrLinearRegressionAggregates() {
|
||||
/**
|
||||
* 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 void testAggregateFunctions(SessionFactoryScope scope) {
|
||||
);
|
||||
}
|
||||
|
||||
@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…
x
Reference in New Issue
Block a user