Skip to content

Commit 50a8ee7

Browse files
committed
Fix LazyOneToManyAssociationWithFetchTest#queryBookWithNamedEntityGraphFetchAuthors
1 parent 7eb5bb6 commit 50a8ee7

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

hibernate-reactive-core/src/test/java/org/hibernate/reactive/LazyOneToManyAssociationWithFetchTest.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,13 @@ public void queryBookWithNamedEntityGraphFetchAuthors(TestContext context) {
208208
.thenCompose( v -> s.persist( terryPratchett ) )
209209
.thenCompose( v -> s.flush() ) )
210210
.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" ) )
214214
.setParameter( 1, goodOmens.getId() )
215215
.getSingleResult() )
216216
.thenAccept( book -> {
217-
context.assertTrue( Hibernate.isInitialized( book.authors ) );
217+
context.assertTrue( Hibernate.isInitialized( book.getAuthors() ) );
218218
List<Author> optionalAssociation = book.authors;
219219
context.assertNotNull( optionalAssociation );
220220
context.assertTrue( optionalAssociation.contains( neilGaiman ) );
@@ -225,12 +225,11 @@ public void queryBookWithNamedEntityGraphFetchAuthors(TestContext context) {
225225
EntityGraph<Author> graph = s.createEntityGraph( Author.class );
226226
graph.addAttributeNodes( "book" );
227227
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 )
230229
.setParameter( 1, neilGaiman.getId() )
231230
.getSingleResult();
232231
} )
233-
.thenAccept( author -> context.assertTrue( Hibernate.isInitialized( author.book ) ) )
232+
.thenAccept( author -> context.assertTrue( Hibernate.isInitialized( author.getBook() ) ) )
234233
);
235234

236235
}

0 commit comments

Comments
 (0)