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 {
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}
Original file line number Diff line number Diff 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 (
You can’t perform that action at this time.
0 commit comments