Fix for some JPA concurrency issues