-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Accessing EntityManager prevents loading of lazy entities #16450
Comments
/cc @FroMage, @loicmathieu |
Would you mind trying to rewrite your example without the Panache APIs? In plain JPA/Hibernate-ORM? That will help us figure out if this is a pure-ORM issue or in the Panache layer. |
@FroMage I replaced the previous example with the one without Panache:
See repro-case-no-panache.zip in post above. It seems Panache has nothing to do with the problem. |
@dreab8 This seems very similar to the problem you are currently working on. Maybe it's the same problem? Otherwise just tell me, and I'll have a closer look. |
I managed to reproduce it in Hibernate and the fix for https://hibernate.atlassian.net/browse/HHH-14549 should resolve this issue |
Describe the bug
Entity A has OneToOne to entity B, which has OneToMany to entity C. Iterating through all A's, B's and all C's.
(see attached project below)
Expected behavior
reproducer_Case1() should pass.
Entities should be retrieved/listed like this:
A1, B1, C1
Actual behavior
... but this happens:
reproducer_Case1() fails... like C1 does not exist:
A1, B1, (access EM here), [C1 dissapears]
To Reproduce
See attached project with test case. Run tests in ReproTest.
Environment (please complete the following information):
Output of
uname -a
orver
Output of
java -version
Quarkus version or git rev
1.13.1.Final
Build tool (ie. output of
mvnw --version
orgradlew --version
)Additional context
If the Transactional annotation is removed, the tests pass. But I need Transactional.
It seems that it does not matter if accessing EM is done through Panache or through EM directly (test reproducer_Case3_NoPanache()).
In certain cases (in the original source code within the real project) listing specific entities causes the problem, while listing entities of other types does not. At first I thought that the entities need a relation to B, but it seems that is not the case. That's why there are two similar test: one with entity UX (UnrelatedX) and one with RX (RelatedX)... does not matter in this setup, though.
The problem happened first in a REST resource.. I managed to create a test case from it.
The only 'workaround' I found is to 'pre-load' all B's before doing the listAll().. but this will cause other problems.
Use this project to reproduce:
repro-case-no-panache.zip
The text was updated successfully, but these errors were encountered: