@@ -208,13 +208,13 @@ public void queryBookWithNamedEntityGraphFetchAuthors(TestContext context) {
208
208
.thenCompose ( v -> s .persist ( terryPratchett ) )
209
209
.thenCompose ( v -> s .flush () ) )
210
210
.thenCompose ( v -> openSession () )
211
- .thenCompose ( s -> s . createQuery ( "from Tome b where b.id=?1" , Book . class )
212
- // FIXME: EntityGraph [ORM-6]
213
- // .setPlan( s.getEntityGraph( Book.class, "withAuthors" ) )
211
+ .thenCompose ( s -> s
212
+ . createQuery ( "from Tome b where b.id=?1" , Book . class )
213
+ .setHint ( "jakarta.persistence.fetchgraph" , s .getEntityGraph ( Book .class , "withAuthors" ) )
214
214
.setParameter ( 1 , goodOmens .getId () )
215
215
.getSingleResult () )
216
216
.thenAccept ( book -> {
217
- context .assertTrue ( Hibernate .isInitialized ( book .authors ) );
217
+ context .assertTrue ( Hibernate .isInitialized ( book .getAuthors () ) );
218
218
List <Author > optionalAssociation = book .authors ;
219
219
context .assertNotNull ( optionalAssociation );
220
220
context .assertTrue ( optionalAssociation .contains ( neilGaiman ) );
@@ -225,12 +225,11 @@ public void queryBookWithNamedEntityGraphFetchAuthors(TestContext context) {
225
225
EntityGraph <Author > graph = s .createEntityGraph ( Author .class );
226
226
graph .addAttributeNodes ( "book" );
227
227
return s .createQuery ( "from Writer w where w.id=?1" , Author .class )
228
- // FIXME: EntityGraph [ORM-6]
229
- // .setPlan( graph )
228
+ .setHint ( "jakarta.persistence.fetchgraph" , graph )
230
229
.setParameter ( 1 , neilGaiman .getId () )
231
230
.getSingleResult ();
232
231
} )
233
- .thenAccept ( author -> context .assertTrue ( Hibernate .isInitialized ( author .book ) ) )
232
+ .thenAccept ( author -> context .assertTrue ( Hibernate .isInitialized ( author .getBook () ) ) )
234
233
);
235
234
236
235
}
0 commit comments