public int getAndIncrementRowCount() {
// Read current value from LogConfigurationData with id=0
final int currentLogEntryRowNumber = LogConfigurationData.findCurrentLogEntryRowNumber(entityManager);
if (currentLogEntryRowNumber == -1) {
// No such LogConfigurationData exists, so we create a new one with an updated logEntryRowNumber...
final LogConfigurationData logConfigurationDataNew = new LogConfigurationData(0, new LogConfiguration());
logConfigurationDataNew.setLogEntryRowNumber(1);
entityManager.persist(logConfigurationDataNew);
// ...and return 0, since we know that this is the first anyone has asked for.
return 0;
} else {
// Try an atomic UPDATE of the logEntryRowNumber based on what we just read