@Override public synchronized void write(final Record record) { try { final RecordDefinition recordDefinition = record.getRecordDefinition(); final RecordStore recordStore = recordDefinition.getRecordStore(); final RecordState state = record.getState(); if (recordStore != this.recordStore) { if (state != RecordState.DELETED) { insert(record); } } else { switch (state) { case NEW: insert(record); break; case MODIFIED: update(record); break; case PERSISTED: // No action required break; case DELETED: delete(record); break; default: throw new IllegalStateException("State not known"); } } } catch (final RuntimeException e) { throw e; } catch (final Error e) { throw e; } catch (final BatchUpdateException e) { for (SQLException e1 = e.getNextException(); e1 != null; e1 = e1.getNextException()) { LOG.error("Unable to write", e1); } throw new RuntimeException("Unable to write", e); } catch (final Exception e) { throw new RuntimeException("Unable to write", e); } }