question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Transaction isolation issue

See original GitHub issue

I’m a long-time dbUnit user and recently learned of this framework, and am trying it on my first product. I really appreciate the annotation approach!

We’re encountering some initial issues and looking for how to solve them (other than a feature enhancement 😃.

Our environment is Spring Boot, Spring Data/JPA, JPA/Hibernate, with Derby for the test db.

The issue is any simple row manipulation causes failure unless we force a flush, e.g.:

// for inserts and updates:
repository.saveAndFlush(entity);

// for deletes:
repository.delete();
repository.flush();

Because the @DatabaseSetup doesn’t commit the prep data (@DatabaseSetup, @ExpectedDatabase, and @DatabaseTearDown run in the same transaction), problems exist with isolation levels disallowing dirty reads and sometimes false-positives based on the database. In my experience, it is better if all of the above steps run in their own transactions. In my prior work using dbUnit directly, the test/dbUnit and the production code each have their own connection and therefore all steps run in separate transactions so never encounter these problems.

How are others working around this without config option to the three annotations to have them each start and commit their own transaction?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:2
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
pecoraladicommented, Mar 8, 2018

Why was this just closed? It’s still broken!! Your library doesn’t work with @Transactional methods. So that rules out using it with lazily loaded JPA entities i.e. I would say MOST of us?

0reactions
philwebbcommented, Apr 14, 2016

I don’t have an immediate answer I’m afraid. If anyone has time to put together a pull-request I’ll happily take a look.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Part 1: How to solve the transactional issues of isolation levels
Transactions specify an isolation level that defines the degree to which one transaction must be isolated from resource or data modifications ...
Read more >
Transaction Isolation Levels (ODBC) - ODBC API Reference
Transaction isolation levels are a measure of the extent to which transaction isolation succeeds. In particular, transaction isolation ...
Read more >
Transaction Isolation Levels in DBMS - GeeksforGeeks
Transaction Isolation Levels in DBMS · Dirty Read – A Dirty read is a situation when a transaction reads data that has not...
Read more >
Documentation: 15: 13.2. Transaction Isolation - PostgreSQL
sees only data committed before the query began; it never sees either uncommitted data or changes committed during query execution by concurrent transactions....
Read more >
Transaction Isolation Levels in MS SQL: Ultimate Guide for ...
At the read committed isolation level (and read uncommitted as well), a non-repeatable read problem can occur. Both transactions use read ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found