Repository navigation
Change the flush mode to auto and fixing check for entities loaded into the session - #10623
Conversation
|
@pedroigor could you please rebase, so I can get it merged? |
…they are loaded in the EM Closes keycloak#10411
|
@abstractj Done. |
There was a problem hiding this comment.
Thanks @pedroigor. I can see there is ongoing discussion at #10411.
In the meantime I checked the PR and it looks good to me. I was trying to debug it locally to see what is going on with the FlushMode. Please see inline for details. Thanks again.
| entityManager = PersistenceExceptionConverter.create(session, emf.createEntityManager()); | ||
| } | ||
|
|
||
| entityManager.setFlushMode(FlushModeType.AUTO); |
There was a problem hiding this comment.
When I debug[1] it locally AUTO mode is already set. As far as I was able to find out AUTO is default. Am I missing something?
[1]
cd quarkus
mvn -f server/pom.xml -Dsuspend=true compile quarkus:dev -Dquarkus.args="start-dev"
|
@vramik Thanks. No, you are not. And the reason is that we are building the EM by ourselves instead of obtaining it from the corresponding extension. The reason I'm forcing the flush mode is to make more clear the mode we are supposed to use, regardless of how the EM is obtained. 8000 |
There was a problem hiding this comment.
@pedroigor thanks. It makes sense.
Closes #10411
FlushMode.AUTOsimilarly to Wildfly dist. By default, it is set toALWAYS.JpaUserProviderto not usePersistenceUnitUtil.isLoadedbutEntityManager.containsto check whether entities are loaded into the sessionThe second one is what behaves differently between Wildfly and Quarkus distribution, Hibernate v5.3 and v5.6, respectively. Accordingly to Hibernate team the usage of
PersistenceUnitUtilis not reliable. See https://github.com/hibernate/hibernate-orm/blob/main/hibernate-core/src/main/java/org/hibernate/jpa/internal/PersistenceUnitUtilImpl.java#L40.