Skip to content

Commit 62db573

Browse files
committed
[#1386] Update example for testing
At the moment we don't have an easy way to test with bytecode enhancements enabled. The examples enable it, so it's the next best thing.
1 parent bdca3fe commit 62db573

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

examples/session-example/src/main/java/org/hibernate/reactive/example/session/Book.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ class Book {
3535
@NotNull @Past
3636
private LocalDate published;
3737

38+
@Basic(fetch = LAZY)
39+
public byte[] coverImage;
40+
3841
@NotNull
3942
@ManyToOne(fetch = LAZY)
4043
private Author author;
@@ -44,6 +47,7 @@ class Book {
4447
this.isbn = isbn;
4548
this.author = author;
4649
this.published = published;
50+
this.coverImage = ("Cover image for '" + title + "'").getBytes();
4751
}
4852

4953
Book() {}
@@ -67,4 +71,8 @@ Author getAuthor() {
6771
LocalDate getPublished() {
6872
return published;
6973
}
74+
75+
byte[] getCoverImage() {
76+
return coverImage;
77+
}
7078
}

examples/session-example/src/main/java/org/hibernate/reactive/example/session/MutinyMain.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,19 @@ public static void main(String[] args) {
147147
// retrieve a Book
148148
session -> session.find( Book.class, book1.getId() )
149149
// fetch a lazy field of the Book
150-
.chain( book -> session.fetch( book, Book_.published )
151-
// print the lazy field
150+
.call( book -> session.fetch( book, Book_.published )
151+
// print one lazy field
152152
.invoke( published -> out.printf(
153153
"'%s' was published in %d\n",
154154
book.getTitle(),
155155
published.getYear()
156156
) )
157157
)
158-
)
158+
.call( book -> session.fetch( book, Book_.coverImage )
159+
// print the other lazy field
160+
.invoke( coverImage -> out.println( new String( coverImage ) ) )
161+
)
162+
)
159163
.await().indefinitely();
160164

161165
factory.withTransaction(

0 commit comments

Comments
 (0)