-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Propagate read-only status as FlushMode.MANUAL to Query instances [SPR-15759] #20314
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
Comments
Juergen Hoeller commented Hibernate 5.2 has refactored its entire JPA handling into the So you're saying that setting the flush mode on the As a side note, a downgrade to Hibernate 5.1.8 might help since that generation still comes with the original Hibernate EntityManager separation: that is, no JPA flush mode at the |
Eduardo Simioni commented I've had assumed too much. After debugging I've had also assumed that the extra time to execute the method was due to Hibernate dirty checking mechanism, but it was due to how Hibernate is populating the results of the query whether it is set to |
Juergen Hoeller commented Well, let's turn this into an improvement request then :-) We can try to propagate the read-only status as FlushMode.MANUAL to |
Eduardo Simioni commented The results may vary, but in our experience changing all queries to |
Juergen Hoeller commented Closing this in favor of #21494 since |
Uh oh!
There was an error while loading. Please reload this page.
Eduardo Simioni opened SPR-15759 and commented
Our setup uses
org.springframework.orm.hibernate5.HibernateTransactionManager
andorg.springframework.orm.hibernate5.LocalSessionFactoryBean
Hibernate 5.2.10.Final
We also use compile time aspects for the transactions, although I don't think this would be a determinant factor for this bug.
The problem
I've put the following code inside a
@Transactional(readOnly = true)
method (the only transactional method in the chain):This yielded the following result:
Plus the following Hibernate log line:
I've noticed this by chance. After setting one of our main queries (single method request) to
FlushMode.MANUAL
, the total request time dropped from 550ms to 110ms on average.Most of the time was being spent on Hibernate checking dirty entities, which led me to conclude that Spring was not setting the
FlushMode
correctly.I'm not sure if this bug is present on 5.0 branch, but since I didn't find any similar issue, I'd guess it is.
Affects: 4.3.9, 5.0 RC2
Issue Links:
The text was updated successfully, but these errors were encountered: