Skip to content

Commit 93c18da

Browse files
committed
more doc updates for JPA 3.2
Signed-off-by: Gavin King <[email protected]>
1 parent 1fa10e3 commit 93c18da

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

documentation/src/main/asciidoc/introduction/Interacting.adoc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,8 +1226,8 @@ We can place the `@NamedQuery` annotation on any class, even on an entity class.
12261226

12271227
[source,java]
12281228
----
1229-
@NamedQuery(name="10BooksByTitle",
1230-
query="from Book where title like :titlePattern order by title fetch first 10 rows only")
1229+
@NamedQuery(name = "10BooksByTitle",
1230+
query = "from Book where title like :titlePattern order by title fetch first 10 rows only")
12311231
class BookQueries {}
12321232
----
12331233

@@ -1256,21 +1256,21 @@ There's much less advantage to using `@NamedNativeQuery`, because there is very
12561256
|===
12571257
| Kind | `Session` method | `EntityManager` method | `Query` execution method
12581258

1259-
| Selection | `createNamedSelectionQuery(String,Class)` | `createNamedQuery(String,Class)` | `getResultList()`, `getSingleResult()`, or `getSingleResultOrNull()`
1260-
| Mutation | `createNamedMutationQuery(String)` | `createNamedQuery(String)` | `executeUpdate()`
1259+
| Selection | `createNamedSelectionQuery(String,Class)` | `createNamedQuery(TypedQueryReference)`, `createNamedQuery(String,Class)` | `getResultList()`, `getSingleResult()`, `getSingleResultOrNull()`
1260+
| Mutation | `createNamedMutationQuery(String)` | `createNamedQuery(TypedQueryReference)`, `createNamedQuery(String)` | `executeUpdate()`
12611261
|===
12621262

12631263
We execute our named query like this:
12641264

12651265
[source,java]
12661266
----
12671267
List<Book> books =
1268-
entityManager.createNamedQuery(BookQueries_.QUERY_10_BOOKS_BY_TITLE)
1268+
entityManager.createQuery(BookQueries_._10BooksByTitle_)
12691269
.setParameter("titlePattern", titlePattern)
12701270
.getResultList()
12711271
----
12721272

1273-
Here, `BookQueries_.QUERY_10_BOOKS_BY_TITLE` is a constant with value `"10BooksByTitle"`, generated by the Hibernate Processor.
1273+
Here, `BookQueries_.\_10BooksByTitle_` is an element of the JPA static metamodel of type `TypedQueryReference<Book>`, generated by Hibernate Processor.
12741274

12751275
Note that the code which executes the named query is not aware of whether the query was written in HQL or in native SQL, making it slightly easier to change and optimize the query later.
12761276

@@ -1293,9 +1293,9 @@ We can do almost anything via HQL, criteria, or native SQL queries.
12931293
But when we already know the identifier of the entity we need, a query can feel like overkill.
12941294
And queries don't make efficient use of the <<second-level-cache,second level cache>>.
12951295

1296-
We met the <<persistence-operations,`find()`>> method earlier.
1297-
It's the most basic way to perform a _lookup_ by id.
1298-
But as we also <<entity-graph,already saw>>, it can't quite do everything.
1296+
We met the `find()` and `findMultiple()` methods <<persistence-operations,earlier>>.
1297+
These are the most basic ways to perform a _lookup_ by id.
1298+
But they can't quite do everything.
12991299
Therefore, Hibernate has some APIs that streamline certain more complicated lookups:
13001300

13011301
.Operations for lookup by id

0 commit comments

Comments
 (0)