diff --git a/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java b/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java index 047b94841333..d1aadb10ce81 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java @@ -1162,7 +1162,7 @@ private RuntimeException convertNamedQueryException(RuntimeException e) { // it also expects an IllegalArgumentException, so wrap UnknownNamedQueryException return new IllegalArgumentException( e.getMessage(), e ); } - else if ( e instanceof IllegalArgumentException) { + else if ( e instanceof IllegalArgumentException ) { return e; } else { diff --git a/hibernate-core/src/main/java/org/hibernate/query/QueryProducer.java b/hibernate-core/src/main/java/org/hibernate/query/QueryProducer.java index 71f3f2870632..2bcafcc83965 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/QueryProducer.java +++ b/hibernate-core/src/main/java/org/hibernate/query/QueryProducer.java @@ -18,9 +18,41 @@ * {@link jakarta.persistence.EntityManager}. They are declared here to allow reuse by * {@code StatelessSession}. *
- * Unlike the corresponding operations of {@code EntityManager}, operations for creating untyped - * instances of {@code Query} are all marked as deprecated. Clients must migrate to the use of - * the equivalent operations which accept a {@link Class} and return a typed {@code Query}. + * Operations like {@link #createQuery(String, Class)}, {@link #createNamedQuery(String, Class)}, + * and {@link #createNativeQuery(String, Class)} accept an instance indicating the return type + * of the query. + *
+ * List<Book> allBooks =
+ * session.createNativeQuery("select * from books order by title", Book.class)
+ * .getResultList();
+ *
+ *
+ * List<String> allTitles =
+ * session.createNativeQuery("select distinct title from books order by title", String.class)
+ * .getResultList();
+ *
+ *
+ * record IsbnAndTitle(String isbn, String title) {}
+ *
+ * List<IsbnAndTitle> allBooks =
+ * session.createNativeQuery("select isbn, title from books order by title", IsbnAndTitle.class)
+ * .getResultList();
+ *
+ *