Skip to content

Commit

Permalink
Update README.md.
Browse files Browse the repository at this point in the history
  • Loading branch information
gk-brown committed Sep 4, 2024
1 parent 503beaa commit c4ce487
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1019,15 +1019,17 @@ This code creates a query that selects all actors appearing in a particular film
```java
var queryBuilder = QueryBuilder.select(Actor.class)
.join(FilmActor.class, Actor.class)
.filterByForeignKey(FilmActor.class, Film.class, "filmID");
.filterByForeignKey(FilmActor.class, Film.class, "filmID")
.ordered(true);
```

Primary and foreign key annotations associated with the `Actor`, `Film`, and `FilmActor` types are used to construct the "join" clause. The resulting query is functionally equivalent to the following SQL:
Primary and foreign key annotations associated with the [`Actor`](https://github.com/HTTP-RPC/Kilo/blob/master/kilo-test/src/main/java/org/httprpc/kilo/test/Actor.java), [`Film`](https://github.com/HTTP-RPC/Kilo/blob/master/kilo-test/src/main/java/org/httprpc/kilo/test/Film.java), and [`FilmActor`](https://github.com/HTTP-RPC/Kilo/blob/master/kilo-test/src/main/java/org/httprpc/kilo/test/FilmActor.java) types are used to construct the "join" clause. The resulting query is functionally equivalent to the following SQL:

```sql
select actor.* from actor
join film_actor on actor.actor_id = film_actor.actor_id
where film_actor.film_id = :filmID
order by actor.last_name asc, actor.first_name asc
```

Insert, update, and delete operations are also supported. See the [pet](https://github.com/HTTP-RPC/Kilo/blob/master/kilo-test/src/main/java/org/httprpc/kilo/test/PetService.java), [catalog](https://github.com/HTTP-RPC/Kilo/blob/master/kilo-test/src/main/java/org/httprpc/kilo/test/CatalogService.java), and [film](https://github.com/HTTP-RPC/Kilo/blob/master/kilo-test/src/main/java/org/httprpc/kilo/test/FilmService.java) service examples for more information.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ public FilmDetail getFilm(
private List<Actor> getActors(Integer filmID) throws SQLException {
var queryBuilder = QueryBuilder.select(Actor.class)
.join(FilmActor.class, Actor.class)
.filterByForeignKey(FilmActor.class, Film.class, "filmID");
.filterByForeignKey(FilmActor.class, Film.class, "filmID")
.ordered(true);

try (var connection = getConnection();
var statement = queryBuilder.prepare(connection);
Expand All @@ -110,7 +111,8 @@ private List<Actor> getActors(Integer filmID) throws SQLException {
private List<Category> getCategories(Integer filmID) throws SQLException {
var queryBuilder = QueryBuilder.select(Category.class)
.join(FilmCategory.class, Category.class)
.filterByForeignKey(FilmCategory.class, Film.class, "filmID");
.filterByForeignKey(FilmCategory.class, Film.class, "filmID")
.ordered(true);

try (var connection = getConnection();
var statement = queryBuilder.prepare(connection);
Expand Down

0 comments on commit c4ce487

Please sign in to comment.