Fetch a lazy association after using getReference doesn't work with Hibernate Reactive
See original GitHub issueIt’s possible to reproduce it adding the following method to HibernateReactiveTestEndpointFetchLazy
:
@GET
@Path("/getReferenceBooksWithMutiny/{authorId}")
public Uni<Collection<Book>> getReferenceBooksWithMutiny(@PathParam("authorId") Integer authorId) {
return Mutiny.fetch(mutinySession.getReference(Author.class, authorId).getBooks());
}
and the test in HibernateReactiveFetchLazyTest
@Test
public void fetchAfterGetReferenceWithMutiny() {
RestAssured.when()
.post("/prepareDb")
.then()
.body(is("Neal Stephenson"));
Response response = RestAssured.when()
.get("/getReferenceBooksWithMutiny/567")
.then()
.extract().response();
assertTitles(response, "Cryptonomicon", "Snow Crash");
}
See my branch: https://github.com/DavideD/quarkus/tree/getreference
This will cause a Session is closed exception. Adding transaction won’t cause any exception but it will return 0 results.
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Hibernate Reactive 1.0.3.Final Reference Documentation
Hibernate Reactive is a reactive API for Hibernate ORM, supporting non-blocking database drivers and a reactive style of interaction with the ...
Read more >5 ways to initialize lazy associations and when to use them
5 ways to initialize lazy associations and when to use them ; 1 1. Call a method on the mapped relation ; 2...
Read more >EntityNotFoundException in Hibernate - Baeldung
In this test, we fetch the Item entity by id. Method find will return an Item object without Category fully initialized since we...
Read more >How to use Hibernate lazy loading and reactive streams?
In this case the problem is that you are trying to lazy load the association after the session has been closed.
Read more >Mutiny.Session (hibernate-reactive-core 1.0.0.Alpha10 API)
Entities associated with an Session do not support transparent lazy association fetching. Instead, fetch(Object) should be used to explicitly request ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think we already cover these cases in Hibernate reactive. See ReferenceTest:
I haven’t verified it, but I suspect this issue is related to this one on Hibernate Reactive: https://github.com/hibernate/hibernate-reactive/issues/975