fix javax package name + minor code example errors

(spotted by @andrei-ivanov)
This commit is contained in:
Gavin 2023-05-29 12:41:23 +02:00 committed by Christian Beikov
parent d1b9424ec4
commit 8fbb62ade8
2 changed files with 5 additions and 5 deletions

View File

@ -601,7 +601,7 @@ for (var result : results) {
This is bearable, but let's explore some other options. This is bearable, but let's explore some other options.
JPA lets us specify that we want each query result packaged as an instance of `javax.persistence.Tuple`. JPA lets us specify that we want each query result packaged as an instance of `jakarta.persistence.Tuple`.
All we have to do is pass the class `Tuple` to `createQuery()`. All we have to do is pass the class `Tuple` to `createQuery()`.
[source, java] [source, java]
@ -630,8 +630,8 @@ var results =
Map.class) Map.class)
.getResultList(); .getResultList();
for (var map : results) { for (var map : results) {
String title = (String) tuple.get("title"); String title = (String) map.get("title");
String preamble = (String) tuple.get("preamble"); String preamble = (String) map.get("preamble");
} }
---- ----
[source, java] [source, java]
@ -643,7 +643,7 @@ var results =
.getResultList(); .getResultList();
for (var list : results) { for (var list : results) {
String title = (String) list.get(0); String title = (String) list.get(0);
String preamble = (String) tuple.get(1); String preamble = (String) list.get(1);
} }
---- ----

View File

@ -1938,7 +1938,7 @@ There's no need to bother with trying to represent a "tuple of length 1".
But if there are multiple expressions in the select list then: But if there are multiple expressions in the select list then:
- by default, each query result is packaged as an array of type `Object[]`, or - by default, each query result is packaged as an array of type `Object[]`, or
- if explicitly requested by passing the class `Tuple` to `createQuery()`, the query result is packaged as an instance of `javax.persistence.Tuple`. - if explicitly requested by passing the class `Tuple` to `createQuery()`, the query result is packaged as an instance of `jakarta.persistence.Tuple`.
[[hql-select-clause-projection-example]] [[hql-select-clause-projection-example]]
//.Query results as lists //.Query results as lists