|
5 | 5 | * Copyright: Red Hat Inc. and Hibernate Authors |
6 | 6 | */ |
7 | 7 |
|
8 | | -//DEPS io.vertx:vertx-pg-client:${vertx.version:4.3.8} |
9 | | -//DEPS io.vertx:vertx-mysql-client:${vertx.version:4.3.8} |
10 | | -//DEPS io.vertx:vertx-db2-client:${vertx.version:4.3.8} |
11 | | -//DEPS org.hibernate.reactive:hibernate-reactive-core:${hibernate-reactive.version:1.1.9.Final} |
12 | | -//DEPS org.slf4j:slf4j-simple:1.7.30 |
13 | | -//DESCRIPTION Allow authentication to PostgreSQL using SCRAM: |
14 | 8 | //DEPS com.ongres.scram:client:2.1 |
| 9 | +//DEPS io.vertx:vertx-pg-client:${vertx.version:4.4.2} |
| 10 | +//DEPS io.vertx:vertx-mysql-client:${vertx.version:4.4.2} |
| 11 | +//DEPS io.vertx:vertx-db2-client:${vertx.version:4.4.2} |
| 12 | +//DEPS org.hibernate.reactive:hibernate-reactive-core:${hibernate-reactive.version:2.0.0.Final} |
| 13 | +//DEPS org.slf4j:slf4j-simple:2.0.7 |
| 14 | +//DESCRIPTION Allow authentication to PostgreSQL using SCRAM: |
15 | 15 |
|
16 | 16 | import java.time.LocalDate; |
17 | 17 | import java.util.ArrayList; |
18 | 18 | import java.util.List; |
| 19 | + |
19 | 20 | import jakarta.persistence.Basic; |
20 | 21 | import jakarta.persistence.Entity; |
21 | 22 | import jakarta.persistence.GeneratedValue; |
|
58 | 59 | * <pre> |
59 | 60 | * podman run --rm --name HibernateTestingPGSQL \ |
60 | 61 | * -e POSTGRES_USER=hreact -e POSTGRES_PASSWORD=hreact -e POSTGRES_DB=hreact \ |
61 | | - * -p 5432:5432 postgres:14 |
| 62 | + * -p 5432:5432 postgres:15.2 |
62 | 63 | * </pre> |
63 | 64 | * </dd> |
64 | 65 | * <dt>3. Run the example with JBang</dt> |
@@ -136,23 +137,23 @@ public static void main(String[] args) { |
136 | 137 | try (Mutiny.SessionFactory factory = createSessionFactory()) { |
137 | 138 | // obtain a reactive session |
138 | 139 | factory.withTransaction( |
139 | | - // persist the Authors with their Books in a transaction |
140 | | - (session, tx) -> session.persistAll( author1, author2 ) |
141 | | - ) |
| 140 | + // persist the Authors with their Books in a transaction |
| 141 | + (session, tx) -> session.persistAll( author1, author2 ) |
| 142 | + ) |
142 | 143 | // wait for it to finish |
143 | 144 | .await().indefinitely(); |
144 | 145 |
|
145 | 146 | out.println(); |
146 | 147 | out.println( "Looking for the book \"" + book1.getTitle() + "\"..." ); |
147 | 148 | factory.withSession( |
148 | | - // retrieve a Book |
149 | | - session -> session.find( Book.class, book1.getId() ) |
150 | | - // author is a lazy association, we need to fetch it first if we want to use it |
151 | | - .chain( book -> session.fetch( book.getAuthor() ) |
152 | | - // print its title and author |
153 | | - .invoke( author -> out.println( "FOUND: \"" + book.getTitle() + "\"" + " by " + author.getName() + " is a great book!" ) ) |
154 | | - ) |
155 | | - ) |
| 149 | + // retrieve a Book |
| 150 | + session -> session.find( Book.class, book1.getId() ) |
| 151 | + // author is a lazy association, we need to fetch it first if we want to use it |
| 152 | + .chain( book -> session.fetch( book.getAuthor() ) |
| 153 | + // print its title and author |
| 154 | + .invoke( author -> out.println( "FOUND: \"" + book.getTitle() + "\"" + " by " + author.getName() + " is a great book!" ) ) |
| 155 | + ) |
| 156 | + ) |
156 | 157 | // wait for it to finish |
157 | 158 | .await().indefinitely(); |
158 | 159 | } |
|
0 commit comments