@Test public void testUpdate() throws Exception { IDataSet db = database( support.loadFlatXmlDataStream(getClass(), "user.xml"), support.loadFlatXmlDataStream(getClass(), "batch.xml") ); support.cleanInsert(support.getConnection(tx), db); tx.commit(); Batch batch = dao.find(1); State expectedState = State.INGESTING; batch.setState(expectedState); String expectedLog = "updated log"; batch.setLog(expectedLog); Timestamp timestamp = batch.getTimestamp(); dao.update(batch); tx.commit(); batch = dao.find(1); assertEquals(expectedState, batch.getState()); assertEquals(expectedLog, batch.getLog()); assertTrue(timestamp.before(batch.getTimestamp())); }
@Override public void update(Batch batch) throws ConcurrentModificationException { DBRecord record = new DBRecord(); Connection c = getConnection(); if (batch.getId() == null) { record.create(table); Timestamp now = new Timestamp(System.currentTimeMillis()); batch.setTimestamp(now); } else { record.read(table, batch.getId(), c); } record.setBeanValues(batch); try { record.update(c); } catch (RecordUpdateInvalidException ex) { throw new ConcurrentModificationException(ex); } getBeanProperties(record, batch); }
EmpireBatchDao extends EmpireDao implements BatchDao { @Override public void update(Batch batch) throws ConcurrentModificationException { DBRecord record = new DBRecord(); Connection c = getConnection(); if (batch.getId() == null) { record.create(table); Timestamp now = new Timestamp(System.currentTimeMillis()); batch.setTimestamp(now); } else { record.read(table, batch.getId(), c); } record.setBeanValues(batch); try { record.update(c); } catch (RecordUpdateInvalidException ex) { throw new ConcurrentModificationException(ex); } getBeanProperties(record, batch); } }
EmpireBatchDao extends EmpireDao implements BatchDao { @Override public void update(Batch batch) throws ConcurrentModificationException { DBRecord record = new DBRecord(); Connection c = getConnection(); if (batch.getId() == null) { record.create(table); Timestamp now = new Timestamp(System.currentTimeMillis()); batch.setTimestamp(now); } else { record.read(table, batch.getId(), c); } record.setBeanValues(batch); try { record.update(c); } catch (RecordUpdateInvalidException ex) { throw new ConcurrentModificationException(ex); } getBeanProperties(record, batch); } EmpireBatchDao(ProarcDatabase db); }
EmpireBatchDao extends EmpireDao implements BatchDao { @Override public void update(Batch batch) throws ConcurrentModificationException { DBRecord record = new DBRecord(); Connection c = getConnection(); if (batch.getId() == null) { record.create(table); Timestamp now = new Timestamp(System.currentTimeMillis()); batch.setTimestamp(now); } else { record.read(table, batch.getId(), c); } record.setBeanValues(batch); try { record.update(c); } catch (RecordUpdateInvalidException ex) { throw new ConcurrentModificationException(ex); } getBeanProperties(record, batch); } EmpireBatchDao(ProarcDatabase db); @Override Batch create(); @Override void update(Batch batch); @Override Batch find(int batchId); @Override Batch findForPid(String pid); @Override List<Batch> findLoadingBatches(); @Override List<BatchView> view(Integer userId, Integer batchId, State state, int offset); @Override List<BatchView> view(Integer userId, Integer batchId, Set<State> state,
            Timestamp from, Timestamp to, int offset, int maxCount, String sortBy); @Override List<BatchView> view(BatchViewFilter filter); }
EmpireBatchDao extends EmpireDao implements BatchDao { @Override public void update(Batch batch) throws ConcurrentModificationException { DBRecord record = new DBRecord(); Connection c = getConnection(); if (batch.getId() == null) { record.create(table); Timestamp now = new Timestamp(System.currentTimeMillis()); batch.setTimestamp(now); } else { record.read(table, batch.getId(), c); } record.setBeanValues(batch); try { record.update(c); } catch (RecordUpdateInvalidException ex) { throw new ConcurrentModificationException(ex); } getBeanProperties(record, batch); } EmpireBatchDao(ProarcDatabase db); @Override Batch create(); @Override void update(Batch batch); @Override Batch find(int batchId); @Override Batch findForPid(String pid); @Override List<Batch> findLoadingBatches(); @Override List<BatchView> view(Integer userId, Integer batchId, State state, int offset); @Override List<BatchView> view(Integer userId, Integer batchId, Set<State> state,
            Timestamp from, Timestamp to, int offset, int maxCount, String sortBy); @Override List<BatchView> view(BatchViewFilter filter);  }