Comments (7)
Yes, I can confirm this is not a regression. We have tested it in several Quarkus versions and the result was always the same.
Thanks.
As we are using Red Hat build of Quarkus in the real-world project where this issue occurred
I would suggest going through Red Hat support if you have a RHBQ subscription, as you will at least have a guarantee of timely answers -- I can't personally guarantee timely answers on all GitHub issues, unfortunately.
Feel free to open a GitHub issue with the full details, and just link to it in your support request.
it might take a while until we can benefit from the fix.
True. Backporting this change is probably not an option, as we have to balance potential improvements against the risk of regression to other users.
Is there a way to override the flush mode configuration manually?
You can call session.setHibernateFlushMode(FlushMode.AUTO)
on a session as a workaround. Make sure to call it as early as possible, before you run queries. That should cover specific code where you saw the problem happen.
Now I suppose you'd want a more "global" workaround that would automatically set the right flush mode on all sessions... I can't see any Hibernate event that would allow you to do this, but assuming you always use transactions for Hibernate sessions, and always use Hibernate sessions in transactions, you could consider registering a CDI event listener:
// Put this in an `@ApplicationScoped` bean somewhere.
void onBeginTransaction(@Observes @Initialized(TransactionScoped.class) Object event, Session session) {
session.setHibernateFlushMode(FlushMode.AUTO);
}
I didn't test this, so I suggest you try it first, and carefully check it solves your problem. But in theory, it should.
from quarkus.
/cc @gsmet (hibernate-orm), @yrodiere (hibernate-orm)
from quarkus.
Hey,
Thanks for reporting.
but as the test shows, a pure Hibernate setup works
One thing you could try is to base your reproducer on https://github.com/hibernate/hibernate-test-case-templates/blob/main/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/QuarkusLikeORMUnitTestCase.java . If it fails there, then it's definitely a problem in Hibernate ORM, but possibly in a feature Quarkus enables by default, like bytecode enhancement. That would justify reporting directly to Hibernate: https://hibernate.atlassian.net/browse/HHH
from quarkus.
Hi Yoann, thanks for the suggestion! I have added a test based on QuarkusLikeORMUnitTestCase
(see https://github.com/lbilger/quarkus-hibernate-batch-fetch-reproducer/tree/main/hibernate-testing). The result is the same as in the ExampleEntityStandaloneTest
, i.e. the batch fetching works.
from quarkus.
Okay that's concerning, we'll need to have closer look. Thanks for checking.
from quarkus.
I had a look at the reproducer, and it turns out:
- Executing a query may trigger an auto-flush, depending on a few things.
- An auto-flush will invalidate all candidates for batch-loading.
- Quarkus explicitly requires that auto-flush always happens, for some reason:
This makes me think this probably isn't a new problem.
@lbilger can you confirm you're not reporting this as a regression, i.e. you don't have a precise version of Quarkus in mind where this used to work as you expect?
I tracked down this choice of using FlushMode.ALWAYS
to... an apparently unrelated commit by some idiot (me): d9ed7bc#diff-3c3d11a887a43713907202d00e1d26f8d664c00c408de92e21904f76f10d7b84R35
I'm really not sure why we would force FlushMode.ALWAYS
... I'll inquire.
EDIT: I started a discussion on the Hibernate chat: https://hibernate.zulipchat.com/#narrow/stream/132094-hibernate-orm-dev/topic/FlushMode.2EALWAYS
from quarkus.
Hi @yrodiere, thanks for investigating and fixing this issue! Yes, I can confirm this is not a regression. We have tested it in several Quarkus versions and the result was always the same.
As we are using Red Hat build of Quarkus in the real-world project where this issue occurred, it might take a while until we can benefit from the fix. Is there a way to override the flush mode configuration manually?
from quarkus.
Related Issues (20)
- SemanticException when use io.quarkus.panache.hibernate.common.runtime.PanacheJpaUtil#getFastCountQuery HOT 1
- App with Infinispan fails after changes in JarFileReference that rarely results in illegal state after changes on ReadWriteLock HOT 14
- Clarify allowed suffix for the log rotation
- Quarkus throws an IllegalArgumentException on startup if a yaml file is too large HOT 3
- Invalid `was not indexed at build time` on application reload HOT 5
- Issue with subscribeAsMessages Method in Quarkus Redis Client HOT 4
- Hibernate Inheritance not persisting to database table HOT 4
- Quarkus exits without showing thrown exception when using `-H:ThrowMissingRegistrationErrors=` HOT 1
- Not all Micrometer metrics are available when exporting with Json HOT 3
- Quarkus 3.10 issue with OpenTelemetry? HOT 7
- Customize list of exceptions to unwrap in resteasy-reactive HOT 9
- Performance Issue with MP Rest Client HOT 3
- Kotlin junit ParameterizedTest with list as argument, not working anymore (3.13.0.CR1) HOT 6
- OpenAPI generates wrong example for URLs HOT 3
- ClassCast Exception with Quarkus Hibernate HOT 2
- Our Nightly Quarkus build deploy to Nexus was failing after the gradle upgrade to 8.9 HOT 3
- Update examples to use org.htmlunit:htmlunit HOT 5
- Core module is using a mix of traditional `@ConfigRoot` and `@ConfigMapping` HOT 5
- Support for Demonstrating Proof of Possession (DPoP) in quarkus-oidc HOT 1
- Add OIDC response filters HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from quarkus.