diff --git a/documentation/src/main/asciidoc/querylanguage/Relational.adoc b/documentation/src/main/asciidoc/querylanguage/Relational.adoc index 7216bd4169..5f46341f7a 100644 --- a/documentation/src/main/asciidoc/querylanguage/Relational.adoc +++ b/documentation/src/main/asciidoc/querylanguage/Relational.adoc @@ -178,6 +178,7 @@ The standard aggregate functions defined in both ANSI SQL and JPQL are these one | `count()`, including `count(distinct)`, `count(all)`, and `count(*)` | Any | `Long` | ✔/✔ | `avg()` | Any numeric type | `Double` | ✔/✔ +| `median()` | Any numeric type | `Double` | ✖/✖ | `min()` | Any numeric type, or string | Same as the argument type | ✔/✔ | `max()` | Any numeric type, or string | Same as the argument type | ✔/✔ | `sum()` | Any numeric type | See table below | ✔/✔ @@ -185,6 +186,9 @@ The standard aggregate functions defined in both ANSI SQL and JPQL are these one | `stddev_pop()`, `stddev_samp()` | Any numeric type | `Double` | ✖/✔ |=== +[NOTE] +The `median()` function is not supported on MySQL or Sybase ASE. + [[aggregate-functions-example]] [source, hql] [%unbreakable] diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/HSQLDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/HSQLDialect.java index 819320c146..9f78bc212e 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/HSQLDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/HSQLDialect.java @@ -62,6 +62,9 @@ import static org.hibernate.type.SqlTypes.NCLOB; /** * A {@linkplain Dialect SQL dialect} for HSQLDB (HyperSQL) 2.6.1 and above. + *
+ * Please refer to the + * HyperSQL User Guide. * * @author Christoph Sturm * @author Phillip Baird diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/FunctionTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/FunctionTests.java index f1f3f6c622..38bbebe181 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/FunctionTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/FunctionTests.java @@ -2316,6 +2316,12 @@ public class FunctionTests { public void testMedian(SessionFactoryScope scope) { scope.inTransaction( session -> { + assertEquals( 1.0, + session.createQuery("select median(e.theDouble) from EntityOfBasics e", Double.class).getSingleResult(), + 1e-5); + assertEquals( 5.0, + session.createQuery("select median(e.theInt) from EntityOfBasics e", Double.class).getSingleResult(), + 1e-5); List