Skip to content

Commit e5620ae

Browse files
committed
Add tagging to Query annotation
1 parent b2026cf commit e5620ae

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

README.adoc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ Page<Package> anotherPage = packages.all(page.nextPageRequest());
219219
```
220220

221221
== The Query Annotation
222-
The `@Query` annotation allows users to write queries using the Jakarta Data Query Language (JDQL). Complex queries can be written concisely using JDQL. JDQL is a strict subset of the Jakarta Persistence Query Language (JPQL).
222+
The [hotspot=Query file=0]`@Query` annotation allows users to write queries using the Jakarta Data Query Language (JDQL). Complex queries can be written concisely using JDQL. JDQL is a strict subset of the Jakarta Persistence Query Language (JPQL).
223223

224224
Packages.java
225225
[source, Java, linenums, role='code_column hide_tags=copyright']
@@ -242,6 +242,14 @@ JDQL supports both named and positional parameters, as well as a number of opera
242242

243243
See the https://jakarta.ee/specifications/data/1.0/jakarta-data-1.0#_jakarta_data_query_language[Jakarta Data specification] for a more comprehensive overview of the Jakarta Data Query Language.
244244

245+
== Running the application
246+
247+
Because you are running the application in dev mode, any changes you make to the code are automatically picked up. You're now ready to test out your queries in the browser.
248+
249+
Point your browser to the http://localhost:9080 URL to access the application. You can select different queries from the list and provide input parameters to see how Jakarta Data retrieves the package data.
250+
251+
Try experimenting with different query parameters to see how the results change. For example, use the `findByLengthGreaterThan` query with different length values to filter packages by length.
252+
245253
== Where to next?
246254
Experiment by creating your own queries. Use the existing ones in the `Packages` class as a starting point and then test them out in the sample application. For example, you could add a query to find packages arriving at a specific destination, which is ordered by width:
247255

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ public interface Packages extends CrudRepository<Package, Integer> {
9898
// tag::query-anno[]
9999

100100
// tag::withAnyDimensionLargerThan[]
101+
// tag::Query[]
101102
@Query("WHERE length > :threshold OR height > :threshold OR width > :threshold")
103+
// end::Query[]
102104
List<Package> withAnyDimensionLargerThan(float threshold);
103105
// end::withAnyDimensionLargerThan[]
104106

0 commit comments

Comments
 (0)