You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `todo-backend` quickstart demonstrates how to implement a backend that exposes a HTTP API with Jakarta RESTful Web Services
20
+
The `todo-jakarta-data` quickstart demonstrates how to implement a backend that exposes a HTTP API with Jakarta RESTful Web Services
21
21
to manage a list of ToDo which are persisted in a database with Jakarta Data.
22
+
It is very similar to the `todo-backend` quickstart but uses Jakarta Data instead of Jakarta Persistence to handle interaction with the backend database.
22
23
23
24
ifndef::ProductRelease[]
24
-
This quickstart shows how to setup a local deployment of this backend as well as a deployment on OpenShift to connect
25
+
This quickstart shows how to set up a local deployment of this backend as well as a deployment on OpenShift to connect
25
26
to a PostgreSQL database also hosted on OpenShift.
26
27
endif::[]
27
28
ifdef::ProductRelease[]
@@ -32,7 +33,7 @@ endif::[]
32
33
33
34
== What is it?
34
35
35
-
The `todo-backend` quickstart demonstrates how to implement a backend that exposes a HTTP API with `Jakarta REST`
36
+
The `todo-jakarta-data` quickstart demonstrates how to implement a backend that exposes a HTTP API with `Jakarta REST`
36
37
to manage a list of ToDo which are persisted in a database with `Jakarta Data`.
37
38
38
39
* The backend exposes a HTTP API to manage a list of todos that complies with the specs defined at https://todobackend.com/specs/index.html[todobackend.com].
@@ -48,6 +49,10 @@ ifdef::ProductRelease[]
48
49
* It is deployed on OpenShift using the https://jbossas.github.io/eap-charts//[Helm Chart for {productName}].
49
50
endif::[]
50
51
52
+
This quickstart
53
+
is the same as the `todo-backend` quickstart, but uses `Jakarta Data` for its persistence layer, instead of `Jakarta Persistence`.
54
+
To see the differences, compare this quickstart's `ToDoRepository` interface with the `ToDoDAO` interface and `ToDoDAOImpl` class in `todo-backend`.
@@ -67,6 +72,7 @@ The layers are defined in the `pom.xml` file in the `<configuration>` section of
67
72
----
68
73
<layers>
69
74
<layer>cloud-server</layer>
75
+
<layer>jakarta-data</layer>
70
76
<layer>postgresql-datasource</layer>
71
77
</layers>
72
78
----
@@ -80,13 +86,16 @@ The layers are defined in the `pom.xml` file in the `<configuration>` section of
80
86
----
81
87
<layers>
82
88
<layer>cloud-server</layer>
89
+
<layer>jakarta-data</layer>
83
90
<layer>postgresql-datasource</layer>
84
91
</layers>
85
92
----
86
93
endif::[]
87
94
88
95
The `cloud-server` layer provides everything needed to run the backend on OpenShift. This also includes access to
89
-
Jakarta EE APIs such as CDI, JAX-RS, JPA, etc. These two layers comes from the {productName} feature pack provided in the
96
+
Jakarta EE APIs such as CDI, Jakarta REST, etc, along with the Hibernate support used by Jakarta Data.
97
+
The `jakarta-data` layer provides the Jakarta Data API.
98
+
These two layers come from the {productName} feature pack provided in the
90
99
{productName} S2I builder image.
91
100
92
101
ifndef::ProductRelease[]
@@ -105,6 +114,33 @@ The Git repository for this feature pack is hosted at https://github.com/jbossas
105
114
It provides JDBC drivers and datasources for different databases but for this quickstart, we will only need the `postgresql-datasource`.
106
115
endif::[]
107
116
117
+
=== Generation of the Jakarta Data Repository implementation
118
+
119
+
A key feature of Jakarta Data is it does not require application developers to write detailed code to write from and write to the backend database.
120
+
Developers just need declare their entities (using Jakarta Persistence annotations like `@Entity`) and then write an repository interface that describes the desired persistence operations, using the Jakarta Data annotations.
121
+
It is then up to the Jakarta Data implementation to generate an implementation of that interface.
122
+
123
+
WildFly's implementation of Jakarta Data, Hibernate Data Repositories, generates that implementation at application build time using an annotation processor run as part of compilation of the application.
124
+
125
+
This is handled in the project `pom.xml` by configuring the `maven-compiler-plugin`:
This value will be different for every installation of the backend.
45
46
46
-
[WARNING]
47
-
====
48
-
Make sure to prepend the host with `https://` to be able to connect to the backend from the ToDo Backend Specs or Client.
49
-
The host must also be publicly accessible.
50
-
====
47
+
To be able to connect to the backend from the ToDo Backend Specs or Client, then prepend the host with `https://`, and append the relative web context `/todo-jakarta-data`. For the previous example host this would be `https://todo-jakarta-data-jmesnil1-dev.apps.sandbox.x8i5.p1.openshiftapps.com/todo-jakarta-data`.
51
48
52
49
We can verify that this application is properly working as a ToDo Backend by running its https://todobackend.com/specs/index.html[specs] on it.
53
50
54
-
55
51
Once all tests passed, we can use the https://todobackend.com/client/index.html[todobackend client] to have a Web application connected to the backend.
0 commit comments