question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fetch a lazy association after using getReference doesn't work with Hibernate Reactive

See original GitHub issue

It’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:closed
  • Created 3 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
DavideDcommented, Mar 19, 2021

I think we already cover these cases in Hibernate reactive. See ReferenceTest:

0reactions
DavideDcommented, Jun 14, 2022

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found