Repository navigation
[WFLY-21081] Add a Jakarta Data quickstart - #1110
bstansberry wants to merge 3 commits into
Conversation
4f38b44 to
b861313
Compare
|
@bstansberry FYI no need to update any README.adoc, those are rebuilt if the related README-source.adoc is changed. You can keep such changes tho, no issue with that. |
|
True. I built that locally because I wanted to read the html page, and then forgot and added that to the commit. |
|
|
||
| By default, it exposes a single datasource. | ||
| In the backend, the name of this datasource is `ToDos` and is specified in the `persistence.xml` to configure JPA: | ||
| In the backend, the name of this datasource is `ToDoRepository` and is specified in the `persistence.xml` to configure JPA: |
There was a problem hiding this comment.
Oops; it seems I made an edit to the wrong file. And even in the todo-jakarta-data QS this isn't correct.
b861313 to
456712e
Compare
|
Considering this was made on top of todo-backend, I suggest to redo this with current todo-backend, to inherit every change we did after this draft PR was submitted |
|
I have update this but the quickstart doesn't work. The server provisioning is not detecting / adding the jakarta-data layer. I'll start a zulip thread to investigate. |
83888b5 to
05145f3
Compare
kstekovi
left a comment
There was a problem hiding this comment.
Reviewed the todo-jakarta-data quickstart - found three areas needing clarification: the update(Long id, ToDo update) logic in ToDoRepository.java:43 may not handle null IDs from PATCH requests correctly, README documentation references incorrect datasource/persistence-unit names in several places, and integration tests don't cover the PATCH/update operation. Otherwise the Jakarta Data implementation looks clean and effectively demonstrates the reduced boilerplate compared to the JPA version.
| * @param update the updated ToDo to persist if one with the id exists. Cannot be {@code null | ||
| * @return an {@link Optional} containing the updated ToDo if a ToDo with {@code id} existed | ||
| */ | ||
| default Optional<ToDo> update(Long id, ToDo update) { |
There was a problem hiding this comment.
In a PATCH request, the update parameter typically has id=null (deserialized from HTTP body without id field). When you call update(update) with a null id, does Jakarta Data's @Update annotation handle this correctly?
There was a problem hiding this comment.
The id should be coming from ToDoController which gets it from the request path, not the HTTP body.
I added two Objects.requireNonNull calls to this method. I went with that because that is what Hibernate Data Repositories does for the other methods in the impl of this interface that it generates. (So, passing null to update(ToDo) will result in "throw new NullPointerException("Null todo").)
|
|
||
| By default the provisioned `postgresql` add-on exposes a single datasource. | ||
|
|
||
| In the backend, the name of this datasource is `ToDoRepository` and is specified in the `persistence.xml` to configure JPA: |
There was a problem hiding this comment.
Should "ToDoRepository" be changed to "ToDos"?
| * `POSTGRESQL_SERVICE_HOST` - the host to connect to the database | ||
| * `POSTGRESQL_SERVICE_PORT` - The port to connect to the database | ||
| * `POSTGRESQL_USER` & `POSTGRESQL_PASSWORD` - the credentials to connect to the database | ||
| * `POSTGRESQL_DATASOURCE` - The name of the datasources (as mentioned above, it will be `ToDoRepository`) |
There was a problem hiding this comment.
Should "ToDoRepository" be changed to "ToDos"?
| * | ||
| * @author Emmanuel Hugonnet (c) 2022 Red Hat, Inc. | ||
| */ | ||
| public class RemoteToDoIT { |
There was a problem hiding this comment.
Should the test coverage include PATCH operation? This would verify the update(Long id, ToDo update) method works correctly (which is questioned in Point 2).
There was a problem hiding this comment.
That would be good, yes.
The test was 100% copied from todo-backend, which doesn't test updates, and should as well. I won't promise to improve todo-backend as part of this but if I have time I will.
There was a problem hiding this comment.
@kstekovi I expanded the test coverage and added a commit doing that for todo-backend as well. I tweaked both quickstarts a bit as well to use the verb 'patch' instead of 'update' for some things, since the semantics of an HTTP PATCH are different from what Jakarta Data defines for @update and from what someone might intuitively expect for a database update.
Thanks for asking about this; the todo-jakarta-data QS wasn't properly doing a PATCH; it was assuming what was provided was a complete ToDo and that all its fields should be persisted. I fixed that.
Note that I still can't actually run the todo-jakarta-data integration test due to the problem I raised in my comment pinging Jean-Francois.
|
@jfdenise This quickstart does not work correctly because wildfly-maven-plugin is not specifying the Jakarta Data layer. The results ^^^ were from a run where I'd updated version.plugin.wildfly to 6.2.0.Final (vs 6.0.3 in this branch), in case that was relevant. I was also testing a 43.0.0.Beta1-SNAPSHOT instead of the 42.0.0.Final in this branch, in case my changes in wildfly/wildfly#20600 helped. I get the same results with the 6.0.3 plugin and 42.0.0.Final. The Arquillian Glow plugin correctly suggests the jakarta-data layer in WF's testsuite/integration/smoke, both with my PR and in 42.x, so I think the layer itself is correct. Any ideas? |
4a9854e to
baf6770
Compare
|
@bstansberry , the smoke tests work because some We should replace the rule values with: |
baf6770 to
b9e1229
Compare
@jfdenise Thanks! wildfly/wildfly#20723 That fixes this QS. I'll put a workaround commit in that we can revert when 43 Beta is integrated with that fix. |
b9e1229 to
83515bb
Compare
…test Rename and document the 'update' operation to properly describe its HTTP PATCH-like semantics Also demonstrate proper cleanup of Jakarta REST client resources in the integration test
83515bb to
e70e8a2
Compare
|
@kstekovi @emmartins @mnovak @scottmarlow This works now. I added a commit that works around the https://redhat.atlassian.net/browse/WFLY-22518 issue that I was discussing with @jfdenise . Once WF 43 Beta with that fixed is integrated that commit can be reverted. |
https://issues.redhat.com/browse/WFLY-21081
This is basically the todo-backend quickstart but with a different persistence layer. The todo-backend QS seems like a perfectly good one for showing a REST CRUD app, and duplicating it makes it easy to see how using Jakarta Data is different from using Jakarta Persistence.
@scottmarlow FYI.