Skip to content

Commit 7de5c71

Browse files
authored
Fix guide. Change JPA Scope for Helidon 3.x. (helidon-io#4170)
1 parent e9ac2a0 commit 7de5c71

1 file changed

Lines changed: 29 additions & 25 deletions

File tree

docs/mp/guides/09_jpa.adoc

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
///////////////////////////////////////////////////////////////////////////////
22

3-
Copyright (c) 2019, 2021 Oracle and/or its affiliates.
3+
Copyright (c) 2019, 2022 Oracle and/or its affiliates.
44

55
Licensed under the Apache License, Version 2.0 (the "License");
66
you may not use this file except in compliance with the License.
@@ -27,7 +27,7 @@ https://jakarta.ee/specifications/persistence/2.2/[Java Persistence
2727
API (JPA)] from within a Helidon MP application.
2828
2929
== What You Need
30-
For this 30 minute tutrial, you'll need the following:
30+
For this 30 minute tutorial, you'll need the following:
3131
3232
include::{common-page-prefix-inc}[tag=common-prereqs-curl]
3333
@@ -146,15 +146,19 @@ Add the following dependencies in your `pom.xml`:
146146
[source,xml]
147147
.`pom.xml`
148148
----
149+
<dependency>
150+
<artifactId>jakarta.ws.rs-api</artifactId>
151+
<scope>compile</scope>
152+
</dependency>
149153
<dependency>
150154
<groupId>jakarta.persistence</groupId>
151155
<artifactId>jakarta.persistence-api</artifactId>
152-
<scope>provided</scope>
156+
<scope>compile</scope>
153157
</dependency>
154158
<dependency>
155159
<groupId>jakarta.transaction</groupId>
156160
<artifactId>jakarta.transaction-api</artifactId>
157-
<scope>provided</scope>
161+
<scope>compile</scope>
158162
</dependency>
159163
----
160164
@@ -275,47 +279,47 @@ public class Greeting implements Serializable { <4>
275279
}
276280
----
277281
278-
<1> (Some of the annotations in this example, like this one, have
282+
<1> (Some annotations in this example, like this one, have
279283
sensible defaults, but the example specifies them explicitly for
280284
clarity.) This
281-
https://jakarta.ee/specifications/persistence/2.2/apidocs/javax/persistence/access[`Access`
285+
https://jakarta.ee/specifications/persistence/3.0/apidocs/javax/persistence/access[`Access`
282286
annotation] says that JPA will access this class' fields directly,
283287
rather than via getter and setter methods.
284288
285289
<2> The
286-
https://jakarta.ee/specifications/persistence/2.2/apidocs/javax/persistence/entity[`Entity`
290+
https://jakarta.ee/specifications/persistence/3.0/apidocs/javax/persistence/entity[`Entity`
287291
annotation] identifies this class as a JPA entity. The
288-
https://jakarta.ee/specifications/persistence/2.2/apidocs/javax/persistence/entity#name()[`name`
292+
https://jakarta.ee/specifications/persistence/3.0/apidocs/javax/persistence/entity#name()[`name`
289293
element] value can be used in JPQL queries.
290294
291295
<3> The
292-
https://jakarta.ee/specifications/persistence/2.2/apidocs/javax/persistence/table[`Table`
296+
https://jakarta.ee/specifications/persistence/3.0/apidocs/javax/persistence/table[`Table`
293297
annotation] identifies the database table to which this class will be
294298
mapped.
295299
296300
<4> JPA entities should be
297-
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/Serializable.html[`Serializable`].
301+
https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/Serializable.html[`Serializable`].
298302
299303
<5> The
300-
https://jakarta.ee/specifications/persistence/2.2/apidocs/javax/persistence/column[`Column`
304+
https://jakarta.ee/specifications/persistence/3.0/apidocs/javax/persistence/column[`Column`
301305
annotation] specifies what column in the database the annotated field
302306
maps to. The elements of the `Column` annotation further describe the
303307
column.
304308
305309
<6> The
306-
https://jakarta.ee/specifications/persistence/2.2/apidocs/javax/persistence/id[`Id`
310+
https://jakarta.ee/specifications/persistence/3.0/apidocs/javax/persistence/id[`Id`
307311
annotation] indicates this field will be mapped to the primary key of
308312
the database table.
309313
310314
<7> The
311-
https://jakarta.ee/specifications/persistence/2.2/apidocs/javax/persistence/basic[`Basic`
315+
https://jakarta.ee/specifications/persistence/3.0/apidocs/javax/persistence/basic[`Basic`
312316
annotation] indicates this field will be mapped to an ordinary
313317
("basic") column.
314318
315319
<8> All JPA entities need a zero-argument constructor, but it doesn't
316320
have to be `public`. This constructor satisfies this requirement. It
317321
is marked
318-
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Deprecated.html[`Deprecated`]
322+
https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Deprecated.html[`Deprecated`]
319323
and is non-`public` so that normal users have to supply data for the
320324
`salutation` and `response` fields via the other constructor.
321325
@@ -329,11 +333,11 @@ Add the following file under `src/main/resources/META-INF`:
329333
.`src/main/resources/META-INF/persistence.xml`
330334
----
331335
<?xml version="1.0" encoding="UTF-8"?>
332-
<persistence version="2.2" <1>
333-
xmlns="http://xmlns.jcp.org/xml/ns/persistence"
336+
<persistence version="3.0" <1>
337+
xmlns="https://jakarta.ee/xml/ns/persistence"
334338
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
335-
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
336-
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd">
339+
xsi:schemaLocation="https://jakarta.ee/xml/xml/ns/persistence
340+
https://jakarta.ee/xml/xml/ns/persistence/persistence_3_0.xsd">
337341
<persistence-unit name="greeting" transaction-type="JTA"> <2>
338342
<description>A persistence unit for the greeting example.</description>
339343
<jta-data-source>greetingDataSource</jta-data-source> <3>
@@ -351,7 +355,7 @@ Add the following file under `src/main/resources/META-INF`:
351355
</persistence>
352356
----
353357
354-
<1> Helidon MP's JPA extension supports JPA 2.2.
358+
<1> Helidon MP's JPA extension supports JPA 3.0.
355359
356360
<2> Note that `JTA` is the transaction type. JTA transactions are
357361
fully supported.
@@ -362,20 +366,20 @@ fully supported.
362366
<4> The `Greeting` class you created is listed here.
363367
364368
<5> The properties listed here are in general
365-
https://www.eclipse.org/eclipselink/documentation/2.7/jpa/extensions/persistenceproperties_ref.htm[EclipseLink
369+
https://www.eclipse.org/eclipselink/documentation/3.0/jpa/extensions/persistenceproperties_ref.htm[EclipseLink
366370
properties]. Many are optional, but a few (detailed below) are required.
367371
368-
<6> https://www.eclipse.org/eclipselink/documentation/2.7/jpa/extensions/persistenceproperties_ref.htm#target-database[This
372+
<6> https://www.eclipse.org/eclipselink/documentation/3.0/jpa/extensions/persistenceproperties_ref.htm#target-database[This
369373
property] is required when EclipseLink is the JPA provider. It is set
370374
to `org.eclipse.persistence.platform.database.H2Platform` because this
371375
example uses the H2 database.
372376
373-
<7> https://www.eclipse.org/eclipselink/documentation/2.7/jpa/extensions/persistenceproperties_ref.htm#target-server[This
377+
<7> https://www.eclipse.org/eclipselink/documentation/3.0/jpa/extensions/persistenceproperties_ref.htm#target-server[This
374378
property] is required, and when EclipseLink is the JPA provider must
375379
have the value
376380
`io.helidon.integrations.cdi.eclipselink.CDISEPlatform`.
377381
378-
<8> https://www.eclipse.org/eclipselink/documentation/2.7/jpa/extensions/persistenceproperties_ref.htm#weaving[This
382+
<8> https://www.eclipse.org/eclipselink/documentation/3.0/jpa/extensions/persistenceproperties_ref.htm#weaving[This
379383
property] is required when EclipseLink is the JPA provider and must be
380384
set to `false`.
381385
@@ -457,9 +461,9 @@ private EntityManager em;
457461
----
458462
459463
<1> The
460-
https://jakarta.ee/specifications/persistence/2.2/apidocs/javax/persistence/persistencecontext[`@PersistenceContext`
464+
https://jakarta.ee/specifications/persistence/3.0/apidocs/javax/persistence/persistencecontext[`@PersistenceContext`
461465
annotation] indicates that you want an
462-
https://jakarta.ee/specifications/persistence/2.2/apidocs/javax/persistence/entitymanager[`EntityManager`]
466+
https://jakarta.ee/specifications/persistence/3.0/apidocs/javax/persistence/entitymanager[`EntityManager`]
463467
injected here.
464468
465469
== Use the Injected `EntityManager`

0 commit comments

Comments
 (0)