From aea72cccd5b77d8fff854c5f8320dad94be12be9 Mon Sep 17 00:00:00 2001 From: Gavin King Date: Sat, 28 Dec 2024 13:55:33 +0100 Subject: [PATCH] HHH-18979 add Order/Restriction to jdoc for @Find and @HQL --- .../annotations/processing/Find.java | 26 ++++++++++++++++++- .../hibernate/annotations/processing/HQL.java | 11 ++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/processing/Find.java b/hibernate-core/src/main/java/org/hibernate/annotations/processing/Find.java index 9cf80e8a6a..bff8e145b2 100644 --- a/hibernate-core/src/main/java/org/hibernate/annotations/processing/Find.java +++ b/hibernate-core/src/main/java/org/hibernate/annotations/processing/Find.java @@ -39,12 +39,25 @@ import static java.lang.annotation.RetentionPolicy.CLASS; * Notice that: * *

+ * Alternatively, a method parameter may have the type + * {@link org.hibernate.query.range.Range Range<T>} where + * {@code T} is the type of the corresponding field in the entity. + *

+ * @Find
+ * Book getBookForIsbn(Range<String> isbn);
+ *
+ * @Find
+ * List<Book> getBooksWithTitle(Range<String> title);
+ * 
+ * This allows the matching field to be restricted based on a variety + * of criteria expressed via the static factory methods of {@code Range}. + *

* It's even possible to query by a field of an embedded object: *

  * @Find
@@ -154,6 +167,17 @@ import static java.lang.annotation.RetentionPolicy.CLASS;
  * 
  • return type {@link org.hibernate.query.KeyedResultList}, and *
  • a parameter of type {@link org.hibernate.query.KeyedPage}. * + *

    + * Finally, a method might have a parameter of type + * {@link org.hibernate.query.Restriction Restriction}, + * allowing the caller to apply an arbitrary filtering criterion to + * the query results. + *

    + * For example: + *

    + * @Find
    + * List<Book> getBooks(Restriction<Book> filter, List<Order<Book>> order);
    + * 
    * * @see HQL * @see SQL diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/processing/HQL.java b/hibernate-core/src/main/java/org/hibernate/annotations/processing/HQL.java index 112f215c95..31ffa23587 100644 --- a/hibernate-core/src/main/java/org/hibernate/annotations/processing/HQL.java +++ b/hibernate-core/src/main/java/org/hibernate/annotations/processing/HQL.java @@ -134,6 +134,17 @@ import static java.lang.annotation.RetentionPolicy.CLASS; *
  • a parameter of type {@link org.hibernate.query.KeyedPage}. * *

    + * Finally, a method might have a parameter of type + * {@link org.hibernate.query.Restriction Restriction}, + * allowing the caller to apply an arbitrary filtering criterion to + * the query results. + *

    + * For example: + *

    + * @HQL("from Book")
    + * List<Book> findBooks(Restriction<Book> filter, List<Order<Book>> order);
    + * 
    + *

    * Queries specified using this annotation are always validated by * the Metamodel Generator, and so it isn't necessary to specify the * {@link CheckHQL} annotation.