-
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
Panache: give a flush() method that pinpoints the right PU #24394
Comments
/cc @FroMage, @loicmathieu |
@lamemind-ud the flush method of the repository should use the right PU, if not, it's a bug. |
I check the code and yes, it flushes on the default entity manager, see https://github.com/quarkusio/quarkus/blob/main/extensions/panache/hibernate-orm-panache/runtime/src/main/java/io/quarkus/hibernate/orm/panache/PanacheRepositoryBase.java#L114 I'll check if we can flush on the right PU instead. |
Thanks @loicmathieu |
@loicmathieu maybe this could help You can get the
|
@lamemind-ud thanks for the tip, you can use it as a workaround on your code. On Panache, we have already the infrastructure to get the correct entity manager, it's used in a lot of places (via bytecode enhancement so not visible on the Quarkus source code) but not on the flush method. |
@loicmathieu
So you can refactor the
|
@lamemind-ud as I said, we have a better alternative for this based on our bytecode enhancement mechanism and some internal classes that already contains this piece of code. |
@lamemind-ud I was wrong and you was right ;) So I use your trick :) |
@loicmathieu I'm glad I have been helpful Cheers |
@lamemind-ud I checked and in fact the current code seems OK, it uses the So, reading the code it seems a JavaDoc issue but maybe I'm wrong. Can you confirm that your have a real issue with the wrong PU being selected or do you open an issue because the JavaDoc tell you the default EntityManager will be used which is not really the case ? |
Hello @loicmathieu , As of my starting comment, the issue here is to have a IMHO, I think Thanks for assistance |
So, this is a mis-understanding of the code: So, it should works (or nothing works as we use the same Each method on Panache that is annotated with |
To be crystal clear.
The
This is already the case. |
I'm gonna check my code before reply... I'll be back :) |
Hello @loicmathieu , I'm back. In my code, with a named PU, if I call Of course, I have no default datasource, cause I have no entities within the default datasource. Can you reproduce? |
Yes, I'll need a reproducer please |
@loicmathieu I cleaned my project. |
Hello @loicmathieu ... I don't know if it can be useful... but I found a way to flush from Actually it's just as simple as
I am a huge noob and I could be wrong... but it seems that Cheers |
Oh yes, I read the code twice but didn't notice it :(
Should be replaced by
So it uses the |
Thanks for spotting the bug. |
And it fact it's what I did three days ago, didn't remember if I did it on purpose and forget that I spotted the bug myself or did it without thinking while modifying the comment ... Anyway I have a PR that fixes the issue openned already ready |
Actually you found the bug. I just pasted some random code |
Fixes quarkusio#24394 (cherry picked from commit bdb2071)
Fixes quarkusio#24394 (cherry picked from commit bdb2071)
Fixes quarkusio#24394 (cherry picked from commit bdb2071)
Description
I'm using multiple named PUs.
There are two ways to
flush()
from a Panache repositorypersistAndFlush()
which is fine IF I want to store an entity itself... But If I run severalupdate()
and then I want to flush, persistAndFlush is not the correct answer.flush()
: it works only on the default PU, which is not my case since the repo's entity is configured within a named PUAny advice?
Implementation ideas
Maybe the
flush()
method could get an argument that pinpoints the right PU (an entity Class instance?)The text was updated successfully, but these errors were encountered: