-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hibernate collections initialized on call to getMyCollection #17291
Comments
Thank you for your report. Unfortunately, I was not able to reproduce your problem with the provided information. In my tests, Please provide a minimal project reproducing the problem. You can for example use this one as the base of your reproducer, changing whatever is necessary to reproduce your problem: https://github.com/yrodiere/quarkus-playground/tree/hibernate-isinitialized |
Hi! You just need to change this line: Containing containing = entityManager.getReference(Containing.class, id); by Containing containing = entityManager.find(Containing.class, id); |
@fabrii that would invalidate the test: |
We are calling Hibernate.isInitialized(containing.getContained()); (The lazy collection) Not Hibernate.isInitialized(containing); |
@Sanne I must admit I'm a bit surprised; is |
ah sorry sure - I was only referring to the object itself, my bad I misunderstood. |
From my experience using Quarkus, when using |
From what I can see, I opened https://hibernate.atlassian.net/browse/HHH-14620 upstream. |
Hi, what's the state of this? I'm using Quarkus 2.11.2 which uses Hibernate 5.6.10 and I still trigger some Hibernate Session interaction by calling myEntity.getMyFetchTypeLazyCollection() while Hibernate.isInitialized(myEntity) == true. Since this happens in a custom serializer when the Session is not active any more, it triggers Hibernate exception. Here's the relevant part of stack trace:
...and here's the part of the entity with mapping annotations: @Override
@OneToMany(targetEntity = Span.E.class, mappedBy = "towerB", fetch = FetchType.LAZY)
public Set<Span> getSpanB() {
return spanB;
} It looks like although the |
@plevart No, the fact that your entity is initialized does not mean its associations are. You If you want to discuss this further, please open a GitHub discussion or a bug report. Reviving old topics is not a great way to get visibility to your comments ;) |
Sorry, I incorrectly assumed this issue was still open. |
I posted this here: #27657 |
Describe the bug
Hibernate.isInitialized(proxy) function is not working properly.
Expected behavior
Return true when the object is initialized.
Return false when the object is not initialized.
Actual behavior
Returns true always.
To Reproduce
Steps to reproduce the behavior:
Environment:
Output of
uname -a
orver
Linux fabricio-desktop 5.4.0-73-generic #82-Ubuntu SMP Wed Apr 14 17:39:42 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Output of
java -version
openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2.20.04)
OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2.20.04, mixed mode, sharing)
Quarkus version or git rev
1.11.3 and 1.13.4
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 11.0.11, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: es_ES, platform encoding: UTF-8
OS name: "linux", version: "5.4.0-73-generic", arch: "amd64", family: "unix"
The text was updated successfully, but these errors were encountered: