@Test public void testUpdate() throws Exception { IDataSet db = database( support.loadFlatXmlDataStream(getClass(), "user.xml"), support.loadFlatXmlDataStream(getClass(), "batch.xml"), support.loadFlatXmlDataStream(getClass(), "batch_item.xml") ); support.cleanInsert(support.getConnection(tx), db); tx.commit(); BatchItem item = dao.find(1); String expectedState = ObjectState.EXCLUDED.name(); item.setState(expectedState); item.setLog(null); dao.update(item); tx.commit(); item = dao.find(1); assertEquals(expectedState, item.getState()); assertNull(item.getLog()); }
@Override public void update(BatchItem item) { DBRecord dbr = new DBRecord(); try { if (item.getId() == null) { dbr.create(table); Timestamp now = new Timestamp(System.currentTimeMillis()); item.setTimestamp(now); } else { dbr.read(table, item.getId(), getConnection()); } dbr.setBeanValues(item); dbr.update(getConnection()); dbr.getBeanProperties(item); } finally { dbr.close(); } }
EmpireBatchItemDao extends EmpireDao implements BatchItemDao { @Override public void update(BatchItem item) { DBRecord dbr = new DBRecord(); try { if (item.getId() == null) { dbr.create(table); Timestamp now = new Timestamp(System.currentTimeMillis()); item.setTimestamp(now); } else { dbr.read(table, item.getId(), getConnection()); } dbr.setBeanValues(item); dbr.update(getConnection()); dbr.getBeanProperties(item); } finally { dbr.close(); } } }
EmpireBatchItemDao extends EmpireDao implements BatchItemDao { @Override public void update(BatchItem item) { DBRecord dbr = new DBRecord(); try { if (item.getId() == null) { dbr.create(table); Timestamp now = new Timestamp(System.currentTimeMillis()); item.setTimestamp(now); } else { dbr.read(table, item.getId(), getConnection()); } dbr.setBeanValues(item); dbr.update(getConnection()); dbr.getBeanProperties(item); } finally { dbr.close(); } } EmpireBatchItemDao(ProarcDatabase db); }
EmpireBatchItemDao extends EmpireDao implements BatchItemDao { @Override public void update(BatchItem item) { DBRecord dbr = new DBRecord(); try { if (item.getId() == null) { dbr.create(table); Timestamp now = new Timestamp(System.currentTimeMillis()); item.setTimestamp(now); } else { dbr.read(table, item.getId(), getConnection()); } dbr.setBeanValues(item); dbr.update(getConnection()); dbr.getBeanProperties(item); } finally { dbr.close(); } } EmpireBatchItemDao(ProarcDatabase db); @Override BatchItem create(); @Override void update(BatchItem item); @Override BatchItem find(int id); @Override List<BatchItem> find(int batchId, String pid, String dsId, String state, String type); @Override void removeItems(int batchId); }
EmpireBatchItemDao extends EmpireDao implements BatchItemDao { @Override public void update(BatchItem item) { DBRecord dbr = new DBRecord(); try { if (item.getId() == null) { dbr.create(table); Timestamp now = new Timestamp(System.currentTimeMillis()); item.setTimestamp(now); } else { dbr.read(table, item.getId(), getConnection()); } dbr.setBeanValues(item); dbr.update(getConnection()); dbr.getBeanProperties(item); } finally { dbr.close(); } } EmpireBatchItemDao(ProarcDatabase db); @Override BatchItem create(); @Override void update(BatchItem item); @Override BatchItem find(int id); @Override List<BatchItem> find(int batchId, String pid, String dsId, String state, String type); @Override void removeItems(int batchId);  }