quarkus: fetch A field relate other class with `@OneToOne(fetch = FetchType.LAZY)` by Mutiny.fetch not work

Describe the bug

fetch A field relate other class with @OneToOne(fetch = FetchType.LAZY) by Mutiny.fetch not work code in https://github.com/paomian/code-with-quarkus can reproduce this error.

Expected behavior

it will get field data.

Actual behavior

throw exception

How to Reproduce?

  1. clone https://github.com/paomian/code-with-quarkus
  2. config your postgresql db or use devservices(I’m not try).
  3. run quarkus dev
  4. run curl localhost:8080/hello
  5. run curl localhost:8080/hello/world/1 maybe should replace [1] to other which return by step 4

Output of uname -a or ver

Darwin paomians-MacBook-Pro.local 21.6.0 Darwin Kernel Version 21.6.0: Mon Aug 22 20:17:10 PDT 2022; root:xnu-8020.140.49~2/RELEASE_X86_64 x86_64

Output of java -version

openjdk version “17.0.5” 2022-10-18 OpenJDK Runtime Environment Temurin-17.0.5+8 (build 17.0.5+8) OpenJDK 64-Bit Server VM Temurin-17.0.5+8 (build 17.0.5+8, mixed mode, sharing)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.13.3.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63) Maven home: /Users/paomian/.m2/wrapper/dists/apache-maven-3.8.6-bin/67568434/apache-maven-3.8.6 Java version: 17.0.5, vendor: Eclipse Adoptium, runtime: /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home Default locale: en_CN, platform encoding: UTF-8 OS name: “mac os x”, version: “12.6”, arch: “x86_64”, family: “mac”

Additional information

I found this https://github.com/quarkusio/quarkus/issues/16638 which similar this issue

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 21 (15 by maintainers)

Most upvoted comments

I know that we have a paragraph in the docs about it. But I think we need more examples. Also, the problem here was a lazy bi one-to-one, not a basic fetch lazy. It seems that depending on which side one wants to fetch, it will need a different approach. I think some HQL won’t work if you select one side of the association.

But I need to have a better look on how we’ve implemented the fetch methods.

You should be able to change the query to load all the info you need without changing the field to EAGER.