Entity Manager is not flushed even if FlushMode ALWAYS is set on Oracle 12c

Description

Hi,

I am running a couple of test from jBPM. I am using application managed transactions so before the start of the transaction I do lookup through JNDI and then I call begin(), I do what I want and then I call commit()/rollback(). And here is the thing: I noticed that when I insert some data into the DB and then in the same transaction I execute a query which obtains previously inserted data, I do not get this data. However when I do commit() and then I query the inserted data, the data are obtained. So I thought that FlushMode AUTO may be the issue so I changed it in persistence.xml to <property name="org.hibernate.flushMode" value="ALWAYS" />. Then I checked if it is properly set by calling em.unwrap(Session.class).getFlushMode() - it is set to ALWAYS as I want. But it behaves the same. It must be said that it happens if and only if I am using Oracle DB, no matter which version, but I tried it mostly with Oracle 12c. When I try it with MySQL or MS SQL for instance, I notice that right before the query to obtain data is going to be executed, Hibernate sends SQL Inserts/Updates to DB so the following query will query them. With Oracle the inserts/updates are sent only after the commit is performed. It is like that regardless the container (JBoss EAP/WLS/WAS). Thanks.

Marian

Activity

Show:

Marian MacikJune 7, 2016 at 2:23 PM
Edited

1) BTW, you do realize that flush mode is just within a Session/EntityManager, right?

By setting <property name="org.hibernate.flushMode" value="ALWAYS" /> every insert is flushed as soon as possible so other em can view fresh data, or not?

2) As far as I know, when JTA is used, these Entity managers should "see each other"
False.

Any clarification on this? JTA is used for global transactions as far as I know, so when I insert something to db via one Entity Manager, when other Entity Managers make Select, it should be available for them if they are in the same transaction.

Thank you for your clarification.

Marian

Steve EbersoleJune 7, 2016 at 1:42 PM

As far as I know, when JTA is used, these Entity managers should "see each other"

False.

Steve EbersoleJune 7, 2016 at 1:41 PM

BTW, you do realize that flush mode is just within a Session/EntityManager, right?

It sounds like you think that the flush mode ought to "stretch" across Session/EntityManager instances... that is not a valid assumption

Steve EbersoleJune 7, 2016 at 1:39 PM

Any test case as we asked for earlier?

Marian MacikJune 7, 2016 at 1:29 PM

Any update on this? Thanks.

Rejected

Details

Assignee

Reporter

Labels

Components

Affects versions

Priority

Created August 12, 2015 at 1:49 PM
Updated December 3, 2024 at 9:06 AM
Resolved June 7, 2016 at 1:43 PM