Skip to content

Commit ad76838

Browse files
authored
Merge pull request #14 from gjwatts/draft
Feedback changes and suggestions
2 parents a9f4e3c + 4d4e96c commit ad76838

File tree

7 files changed

+39
-31
lines changed

7 files changed

+39
-31
lines changed

README.adoc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ include::{common-includes}/gitclone.adoc[]
3939
[role='command']
4040
include::{common-includes}/twyb-intro.adoc[]
4141

42-
Go to the http://localhost:9080 URL to see all the application. You will see a column of queries, some of which will accept input. To start find the `findAll` query with no inputs. Selecting this will return all of the packages similar to the following:
42+
Go to the http://localhost:9080 URL to see all the application data. You will see a column of queries, some of which will accept input. To start find the `findAll` query with no inputs. Selecting this will return all of the packages similar to the following:
4343

4444
```
4545
id = 1 length = 10 width = 20 height = 10 destination = Rochester
@@ -57,7 +57,7 @@ You can then try some of the queries which use input to see how it changes the r
5757

5858
== Creating an Entity and Repository
5959

60-
In Jakarta Data an entity defines the structure for persisting a piece of data. This structure is represented by a Java object and it's associated fields. Start by creating a simple record class.
60+
In Jakarta Data an entity defines the structure for persisting a piece of data. This structure is represented by a Java object and its associated fields. Start by creating a simple record class.
6161

6262
[role="code_command hotspot file=0", subs="quotes"]
6363
----
@@ -161,8 +161,8 @@ List<Package> sortedByHeightAscending();
161161
@OrderBy(value = "height", descending = true)
162162
```
163163
//TODO rename? Runtime Modifications...?
164-
== Sort, Limit, and Paging
165-
Jakarta Data provides the `Sort` class and the `@Limit` annotation to create queries which can be modified at runtime. It also includes a mechanism for paging to better handle large sets of results.
164+
== Sort, Limit, and Pagination
165+
Jakarta Data provides the `Sort` class and the `@Limit` annotation to create queries which can be modified at runtime. It also includes a mechanism for pagination to better handle large sets of results.
166166

167167
----
168168
#Update the `Packages.java` class.#
@@ -210,7 +210,7 @@ When querying large amounts of data, paging is possible by providing a `PageRequ
210210

211211
```java
212212
@Find
213-
Page<Package> allWithPaging(PageRequest pageRequest);
213+
Page<Package> allWithPaging(PageRequest pageRequest); // TODO: Provide more realistic examples(?) with limits?
214214
```
215215

216216
A `PageRequest` can be constructed with the `PageRequest` class's static methods. To request the first page with a page size of 20 results:
@@ -257,4 +257,5 @@ See the Jakarta Data specification for a more comprehensive overview of the Jaka
257257
== Where to next?
258258
Try out the sample application by creating your own queries. Add your own queries to the `Packages` class like the provided ones and then try them out in the sample application.
259259

260-
//Eventually link to an Advanced Guide as well.
260+
//Eventually link to an Advanced Guide as well.
261+
//Include Static Metamodel

finish/pom.xml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,16 @@
2222
<dependencies>
2323
<!-- Provided dependencies -->
2424
<dependency>
25+
<!--
2526
<groupId>jakarta.platform</groupId>
2627
<artifactId>jakarta.jakartaee-api</artifactId>
2728
<version>11.0.0-M4</version>
2829
<scope>provided</scope>
30+
-->
31+
<groupId>jakarta.platform</groupId>
32+
<artifactId>jakarta.jakartaee-api</artifactId>
33+
<version>11.0.0</version>
34+
<scope>provided</scope>
2935
</dependency>
3036
<!-- For tests -->
3137
<dependency>
@@ -61,18 +67,17 @@
6167
<artifactId>liberty-maven-plugin</artifactId>
6268
<version>3.8.2</version>
6369
<configuration>
64-
<!--
6570
<assemblyArtifact>
6671
<groupId>io.openliberty.beta</groupId>
6772
<artifactId>openliberty-runtime</artifactId>
68-
<version>25.0.0.4-beta</version>
73+
<version>25.0.0.8-beta</version>
6974
<type>zip</type>
7075
</assemblyArtifact>
71-
-->
72-
<!-- Nightly until CDI fix is in beta-->
76+
<!-- Nightly until CDI fix is in beta
7377
<install>
7478
<runtimeUrl>https://public.dhe.ibm.com/ibmdl/export/pub/software/openliberty/runtime/nightly/2025-05-23_1102/openliberty-all-25.0.0.6-cl250620250523-1102.zip</runtimeUrl>
7579
</install>
80+
-->
7681
<copyDependencies>
7782
<dependencyGroup>
7883
<!-- Relative to server config directory -->

finish/src/main/java/io/openliberty/guides/data/DbInit.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void init(@Observes Startup event) {
3535
packages.insert(new Package(6, 8f, 5f, 3f, "Rochester"));
3636
packages.insert(new Package(7, 16f, 3f, 15f, "RTP"));
3737
packages.insert(new Package(8, 2f, 15f, 18f, "Rochester"));
38-
38+
// TODO: Add more examples
3939
}
4040
}
4141
}

finish/src/main/java/io/openliberty/guides/data/Package.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,5 @@ public record Package(int id, float length, float width, float height,
2020
String destination) {
2121
// tag::app-only[]
2222

23-
JsonObjectBuilder toJson() {
24-
JsonObjectBuilder json = Json.createObjectBuilder();
25-
json.add("id", id);
26-
json.add("length", length);
27-
json.add("width", width);
28-
json.add("height", height);
29-
json.add("destination", destination);
30-
return json;
31-
}
3223
// end::app-only[]
3324
}

finish/src/main/java/io/openliberty/guides/data/PackageQueryService.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ public class PackageQueryService {
4343
@Inject
4444
Packages packages;
4545

46+
// Remove code to make this a basic example the does something more simple?
47+
4648
// TODO see if some of these could be included
4749
static List<String> excludedMethods = new ArrayList<String>();
4850
static {
@@ -133,8 +135,8 @@ public String callQuery(String jsonString) {
133135
params.add(getTypedValue(jsonParams, i, types.get(i)));
134136
}
135137

136-
Method method = Packages.class.getMethod(json.getString("method"),
137-
types.toArray(new Class<?>[0]));
138+
// TODO: Consider not using reflection and going with a more basic user friendly
139+
Method method = Packages.class.getMethod(json.getString("method"), types.toArray(new Class<?>[0]));
138140
checkForID(method, params);
139141
Object result = method.invoke(packages, params.toArray());
140142

@@ -225,4 +227,18 @@ void checkForID(Method method, List<Object> params) {
225227
boolean excludedMethods(Method m) {
226228
return excludedMethods.contains(m.getName());
227229
}
230+
231+
public record Package(int id, float length, float width, float height,
232+
String destination) {
233+
234+
JsonObjectBuilder toJson() {
235+
JsonObjectBuilder json = Json.createObjectBuilder();
236+
json.add("id", id);
237+
json.add("length", length);
238+
json.add("width", width);
239+
json.add("height", height);
240+
json.add("destination", destination);
241+
return json;
242+
}
243+
}
228244
}

finish/src/main/liberty/config/server.xml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
<server description="Intro REST Guide Liberty server">
1+
<server description="Intro to Jakarta Data Guide Liberty server">
22

33
<featureManager>
44
<feature>restfulWS-4.0</feature>
55
<feature>cdi-4.1</feature>
66
<feature>data-1.0</feature>
77
<feature>persistence-3.2</feature>
8-
<feature>enterpriseBeans-4.0</feature>
98
<feature>requestTiming-1.0</feature>
109
</featureManager>
1110

@@ -26,7 +25,4 @@
2625
<properties.derby.embedded databaseName="memory:testDB" createDatabase="create"/>
2726
</dataSource>
2827

29-
<!-- TODO remove -->
30-
<logging traceSpecification="*=info:data=all:persistenceService=all"/>
31-
3228
</server>

start/pom.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,17 @@
6161
<artifactId>liberty-maven-plugin</artifactId>
6262
<version>3.8.2</version>
6363
<configuration>
64-
<!--
6564
<assemblyArtifact>
6665
<groupId>io.openliberty.beta</groupId>
6766
<artifactId>openliberty-runtime</artifactId>
68-
<version>25.0.0.4-beta</version>
67+
<version>25.0.0.8-beta</version>
6968
<type>zip</type>
7069
</assemblyArtifact>
71-
-->
72-
<!-- Nightly until CDI fix is in beta-->
70+
<!-- Nightly until CDI fix is in beta
7371
<install>
7472
<runtimeUrl>https://public.dhe.ibm.com/ibmdl/export/pub/software/openliberty/runtime/nightly/2025-05-23_1102/openliberty-all-25.0.0.6-cl250620250523-1102.zip</runtimeUrl>
7573
</install>
74+
-->
7675
<copyDependencies>
7776
<dependencyGroup>
7877
<!-- Relative to server config directory -->

0 commit comments

Comments
 (0)