File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
examples/session-example/src/main/java/org/hibernate/reactive/example/session Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,9 @@ class Book {
35
35
@ NotNull @ Past
36
36
private LocalDate published ;
37
37
38
+ @ Basic (fetch = LAZY )
39
+ public byte [] coverImage ;
40
+
38
41
@ NotNull
39
42
@ ManyToOne (fetch = LAZY )
40
43
private Author author ;
@@ -44,6 +47,7 @@ class Book {
44
47
this .isbn = isbn ;
45
48
this .author = author ;
46
49
this .published = published ;
50
+ this .coverImage = ("Cover image for '" + title + "'" ).getBytes ();
47
51
}
48
52
49
53
Book () {}
@@ -67,4 +71,8 @@ Author getAuthor() {
67
71
LocalDate getPublished () {
68
72
return published ;
69
73
}
74
+
75
+ byte [] getCoverImage () {
76
+ return coverImage ;
77
+ }
70
78
}
Original file line number Diff line number Diff line change @@ -147,15 +147,19 @@ public static void main(String[] args) {
147
147
// retrieve a Book
148
148
session -> session .find ( Book .class , book1 .getId () )
149
149
// 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
152
152
.invoke ( published -> out .printf (
153
153
"'%s' was published in %d\n " ,
154
154
book .getTitle (),
155
155
published .getYear ()
156
156
) )
157
157
)
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
+ )
159
163
.await ().indefinitely ();
160
164
161
165
factory .withTransaction (
You can’t perform that action at this time.
0 commit comments