Reputation: 1948
There are two threads, and two transactions bound to each thread:
DEBUG o.s.orm.jpa.JpaTransactionManager - Creating new transaction with name [com.workflow.consumer.RecordEventConsumer$MockitoMock$1882263982.handleRecordsAddedEvent]: PROPAGATION_REQUIRED,ISOLATION_READ_UNCOMMITTED; ''
Creating new transaction with name [com.workflow.statemachine.action.CreateContentAction.execute]: PROPAGATION_REQUIRED,ISOLATION_READ_UNCOMMITTED; ''
Both isolation levels are READ_UNCOMMITTED
. But when first thread insert something in database with
repository.saveAndFlush(contextObject)
Where repository is JpaRepository<T, I> repository
And there are actual logs that insertion happened DEBUG org.hibernate.SQL - insert into task_unit ...etc
The transaction from second thread still could not retrieve this very object with neither of this:
repository.getOne(id);
repository.findOne(id);
entityManager.find(class, id);
More than this, I've tried to connect to the db directly and fire
BEGIN TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SELECT * from task_unit
And still no success.
Do I miss something ?
Upvotes: 2
Views: 1450
Reputation: 51426
If I read your question right, then this manual excepr answers:
https://www.postgresql.org/docs/9.6/static/transaction-iso.html
In PostgreSQL, you can request any of the four standard transaction isolation levels, but internally only three distinct isolation levels are implemented, i.e. PostgreSQL's Read Uncommitted mode behaves like Read Committed. This is because it is the only sensible way to map the standard isolation levels to PostgreSQL's multiversion concurrency control architecture.
emphasis mine
Upvotes: 6