I have two processes using the same entities in the same table. When I read the row from process A, then write from process B, then read again from process A, i get the value before the write of B.
I know that I can use entityManager.refresh(entity) on the entity after each find() operation to get the correct one, but since hibernate receives the updated value from the database even WITHOUT doing refresh(), I would like to ask: What other options do I have?
Here are the log lines with log level TRACE, starting with the line that shows hibernate receives the update value (en-US) from the database, and ending with the log line from my code showing that the entity has the old value (de-DE)
[18:32:52] [ForkJoinPool.commonPool-worker-2/TRACE] [org.hibernate.orm.jdbc.extract]: extracted value ([4] : [VARCHAR]) - [en-US]
[18:32:52] [ForkJoinPool.commonPool-worker-2/TRACE] [org.hibernate.orm.results.loading]: StandardRowReader#readRow
[18:32:52] [ForkJoinPool.commonPool-worker-2/TRACE] [org.hibernate.orm.results.loading.entity]: (o.h.s.r.g.e.i.EntityResultInitializer) Beginning Initializer#resolveKey process for entity : mypackage.SettingValueEntity(e)
[18:32:52] [ForkJoinPool.commonPool-worker-2/DEBUG] [org.hibernate.orm.results]: Extracted JDBC value [0] - [3]
[18:32:52] [ForkJoinPool.commonPool-worker-2/DEBUG] [org.hibernate.orm.results.loading.entity]: (EntityResultInitializer) Hydrated EntityKey (mypackage.SettingValueEntity(e)): 3
[18:32:52] [ForkJoinPool.commonPool-worker-2/TRACE] [org.hibernate.orm.results.loading.entity]: (o.h.s.r.g.e.i.EntityResultInitializer) Beginning Initializer#resolveInstance process for entity (mypackage.SettingValueEntity(e)) : 3
[18:32:52] [ForkJoinPool.commonPool-worker-2/DEBUG] [org.hibernate.orm.results]: Extracted JDBC value [2] - [LANGUAGE]
[18:32:52] [ForkJoinPool.commonPool-worker-2/TRACE] [org.hibernate.orm.results.loading.entity]: (o.h.s.r.g.e.i.EntitySelectFetchInitializer) Beginning Initializer#resolveInstance process for entity (mypackage.SettingValueEntity(e).setting) : LANGUAGE
[18:32:52] [ForkJoinPool.commonPool-worker-2/DEBUG] [org.hibernate.orm.results.loading]: Calling top-level assembler (0 / 1) : org.hibernate.sql.results.graph.entity.internal.EntityAssembler@27100cef
[18:32:52] [ForkJoinPool.commonPool-worker-2/TRACE] [org.hibernate.orm.results.loading]: StandardRowReader#afterRow
[18:32:52] [ForkJoinPool.commonPool-worker-2/TRACE] [org.hibernate.engine.internal.StatefulPersistenceContext]: Initializing non-lazy collections
[18:32:52] [Velocity - Task Executor #0/INFO] [com.velocitypowered.proxy.console.VelocityConsole]: SettingBasedLocaleService.loadLocale(df252223-4d16-4abc-a8cd-f7228a25fa88) => de-DE