If the modification is done in the same transaction, and you use Repeatable Read, then you are allowed to see your own changes.
If the modification is done using a secondary transaction, and you use Repeatable Read, then your first transaction is not allowed to see the changes done by the second transaction. This is because non-repeatable reads are prevented by the Repeatable Read isolation level.
Now, the Hibernate Session
or EntityManager
work like a transaction write behind cache which provides application-level repeatable reads for changes happening via Hibernate, not via native SQL queries.
You can circumvent the first-level cache in two ways:
- either you fetch a DTO instead of the entity
- you
evict
the entity first and fetch it again