Last Updated: February 25, 2016
·
1.041K
· andreitr

FlushMode.COMMIT error during testing

Got this mysterious error message while running integration tests:

Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition...

This threw me off since I've never seen this error before nor made any changes to that particular integration tests / class. When I tested the application manually everything worked as expected...

As it turned out the problem was with a seemingly unrelated domain class which was not properly persisted [in the test] and returned an error in the object.save() call. Since the error message does not indicate the cause of the problem this fairly simple issue was tough to debug.