}
/* Perform buffered modifications */
for (RowItem item : modifiedItems) {
- if (queryDelegate.storeRow(item) > 0) {
- /*
- * Also reset the modified state in the item in case it is
- * reused e.g. in a form.
- */
- item.commit();
- } else {
- queryDelegate.rollback();
- refresh();
- throw new ConcurrentModificationException(
- "Item with the ID '" + item.getId()
- + "' has been externally modified.");
+ if (!removedItems.containsKey(item.getId())) {
+ if (queryDelegate.storeRow(item) > 0) {
+ /*
+ * Also reset the modified state in the item in case it
+ * is reused e.g. in a form.
+ */
+ item.commit();
+ } else {
+ queryDelegate.rollback();
+ refresh();
+ throw new ConcurrentModificationException(
+ "Item with the ID '" + item.getId()
+ + "' has been externally modified.");
+ }
}
}
/* Perform buffered additions */
.getValue());
}
+ @Test
+ public void commit_removeModifiedItem_shouldSucceed() throws SQLException {
+ TableQuery query = new TableQuery("people", connectionPool,
+ SQLTestsConstants.sqlGen);
+ SQLContainer container = new SQLContainer(query);
+ int size = container.size();
+ Object key = container.firstItemId();
+ Item row = container.getItem(key);
+ row.getItemProperty("NAME").setValue("Pekka");
+ Assert.assertTrue(container.removeItem(key));
+ container.commit();
+ Assert.assertEquals(size - 1, container.size());
+ }
+
@Test
public void rollback_tableItemAdded_discardsAddedItem() throws SQLException {
SQLContainer container = new SQLContainer(new TableQuery("people",