Problem with Locking During Unit Tests
624666May 19 2009 — edited Jun 26 2009I have an application that contains a number of JPA entities - many of which have references to others. These references form a hierarchy - I don't believe there are any circular references.
My unit tests will create an instance of entity A and then 3 instances of entity B - and all of those entities will be persisted. It will then pass the collection of B to the reference in A. A is then merged.
So far, so good.
My unit tests have a method that is run after each test method (although there is actually only one test method) which simply deletes all the test data created during the tests - using a Query object. This always hangs - apparently due to a database lock. Certainly, I'm getting errors with lock timeouts on the database. I've tried both SQL Server & MySQl with the same result.
I've spent a while googling around about locking problems - but can't find anything that might be related. I'm using Toplink 2.0.
Can anyone suggest a way forward?