Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ include::{common-includes}/gitclone.adoc[]
[role='command']
include::{common-includes}/twyb-intro.adoc[]

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:
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:

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

== Creating an Entity and Repository

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.
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.

[role="code_command hotspot file=0", subs="quotes"]
----
Expand Down Expand Up @@ -161,8 +161,8 @@ List<Package> sortedByHeightAscending();
@OrderBy(value = "height", descending = true)
```
//TODO rename? Runtime Modifications...?
== Sort, Limit, and Paging
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.
== Sort, Limit, and Pagination
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.

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

```java
@Find
Page<Package> allWithPaging(PageRequest pageRequest);
Page<Package> allWithPaging(PageRequest pageRequest); // TODO: Provide more realistic examples(?) with limits?
```

A `PageRequest` can be constructed with the `PageRequest` class's static methods. To request the first page with a page size of 20 results:
Expand Down Expand Up @@ -257,4 +257,5 @@ See the Jakarta Data specification for a more comprehensive overview of the Jaka
== Where to next?
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.

//Eventually link to an Advanced Guide as well.
//Eventually link to an Advanced Guide as well.
//Include Static Metamodel
13 changes: 9 additions & 4 deletions finish/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@
<dependencies>
<!-- Provided dependencies -->
<dependency>
<!--
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>11.0.0-M4</version>
<scope>provided</scope>
-->
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>11.0.0</version>
<scope>provided</scope>
</dependency>
<!-- For tests -->
<dependency>
Expand Down Expand Up @@ -61,18 +67,17 @@
<artifactId>liberty-maven-plugin</artifactId>
<version>3.8.2</version>
<configuration>
<!--
<assemblyArtifact>
<groupId>io.openliberty.beta</groupId>
<artifactId>openliberty-runtime</artifactId>
<version>25.0.0.4-beta</version>
<version>25.0.0.8-beta</version>
<type>zip</type>
</assemblyArtifact>
-->
<!-- Nightly until CDI fix is in beta-->
<!-- Nightly until CDI fix is in beta
<install>
<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>
</install>
-->
<copyDependencies>
<dependencyGroup>
<!-- Relative to server config directory -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void init(@Observes Startup event) {
packages.insert(new Package(6, 8f, 5f, 3f, "Rochester"));
packages.insert(new Package(7, 16f, 3f, 15f, "RTP"));
packages.insert(new Package(8, 2f, 15f, 18f, "Rochester"));

// TODO: Add more examples
}
}
}
9 changes: 0 additions & 9 deletions finish/src/main/java/io/openliberty/guides/data/Package.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,5 @@ public record Package(int id, float length, float width, float height,
String destination) {
// tag::app-only[]

JsonObjectBuilder toJson() {
JsonObjectBuilder json = Json.createObjectBuilder();
json.add("id", id);
json.add("length", length);
json.add("width", width);
json.add("height", height);
json.add("destination", destination);
return json;
}
// end::app-only[]
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public class PackageQueryService {
@Inject
Packages packages;

// Remove code to make this a basic example the does something more simple?

// TODO see if some of these could be included
static List<String> excludedMethods = new ArrayList<String>();
static {
Expand Down Expand Up @@ -133,8 +135,8 @@ public String callQuery(String jsonString) {
params.add(getTypedValue(jsonParams, i, types.get(i)));
}

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

Expand Down Expand Up @@ -225,4 +227,18 @@ void checkForID(Method method, List<Object> params) {
boolean excludedMethods(Method m) {
return excludedMethods.contains(m.getName());
}

public record Package(int id, float length, float width, float height,
String destination) {

JsonObjectBuilder toJson() {
JsonObjectBuilder json = Json.createObjectBuilder();
json.add("id", id);
json.add("length", length);
json.add("width", width);
json.add("height", height);
json.add("destination", destination);
return json;
}
}
}
6 changes: 1 addition & 5 deletions finish/src/main/liberty/config/server.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<server description="Intro REST Guide Liberty server">
<server description="Intro to Jakarta Data Guide Liberty server">

<featureManager>
<feature>restfulWS-4.0</feature>
<feature>cdi-4.1</feature>
<feature>data-1.0</feature>
<feature>persistence-3.2</feature>
<feature>enterpriseBeans-4.0</feature>
<feature>requestTiming-1.0</feature>
</featureManager>

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

<!-- TODO remove -->
<logging traceSpecification="*=info:data=all:persistenceService=all"/>

</server>
7 changes: 3 additions & 4 deletions start/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,17 @@
<artifactId>liberty-maven-plugin</artifactId>
<version>3.8.2</version>
<configuration>
<!--
<assemblyArtifact>
<groupId>io.openliberty.beta</groupId>
<artifactId>openliberty-runtime</artifactId>
<version>25.0.0.4-beta</version>
<version>25.0.0.8-beta</version>
<type>zip</type>
</assemblyArtifact>
-->
<!-- Nightly until CDI fix is in beta-->
<!-- Nightly until CDI fix is in beta
<install>
<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>
</install>
-->
<copyDependencies>
<dependencyGroup>
<!-- Relative to server config directory -->
Expand Down