Luuk D. Jansen
Luuk D. Jansen

Reputation: 4506

JPA and concurrent transactions with MySQL

I am not a DB expert, so maybe somebody can help me out with the following. I use JPA icm MySQL on the Play! Framework.

As I in the past ran into problems with DB locks on a data collection routine, I made this routine read-only. Now when I need to make changes from this routine I do it concurrently. Worked fine so far, but now I run into a problem. When a new user connects a record is created and the ID passed back. But I need to get the Model, not just the id.

When I search for the 'id' on my test environment this is fine, I just search for it (mem db) but with MYSQL the EM returns with nothing. It seems to me that with JPA-MySQL no changes made before the transaction start (even if bread-only) are included in future searches.

Is this correct, and is there a way around this? I can rewrite the procedure to make it readable again, and see if I can optimise it more so it would not result in other threads (or server) to run into a problem in obtaining a db lock. Possibly the best in the long term, but I am looking for a quicker solution for the moment.

Upvotes: 0

Views: 242

Answers (1)

Luuk D. Jansen
Luuk D. Jansen

Reputation: 4506

The Transaction Isolation Level was set too high. Changing it solved the problem. In the Play! Framework (1.2.5) it can be done like this:

%prod-test.db.isolation=READ_COMMITTED

Upvotes: 1

Related Questions