JPA: Retrying to create request fails

In a Java SE application using EclipseLink 2.0, some data is updated in the database as follows:

public void updateDepartment(int from, int to) {

    entityManager.getTransaction().begin();
    List<String> uuidList = getEmployeeUuids(from);

    entityManager.createQuery("UPDATE Employee SET department = :department WHERE uuid IN :uuidList")
            .setParameter("uuidList", uuidList)
            .setParameter("department", to)
            .executeUpdate();

    entityManager.getTransaction().commit();
}

      

Everything works as expected. Immediately after this, another query is created that reads some data from the database using the same entityManager

.

Finally, the application calls the method again updateDeparment(int from, int to)

. Only this time it fails to create a request, displaying the following warning:

The class RepeatableWriteUnitOfWork is already flushing. The query will be 
executed without further changes being written to the database.  If the query
is conditional upon changed data the changes may not be reflected in the results. 
Users should issue a flush() call upon completion of the dependent changes and 
prior to this flush() to ensure correct results.

      

The database is not subsequently updated.

I have not found any other mention of this warning on the internet.

Debugging the application I noticed eliminating code that reads data from the database between two method calls updateDeparment(int from, int to)

solves the problem. But I can't see what is causing this behavior and what exactly is the EclipseLink warning.

+3


source to share





All Articles