@Test public void testUpdate() throws Exception { IDataSet db = database( support.loadFlatXmlDataStream(getClass(), "group.xml") ); support.cleanInsert(support.getConnection(tx), db); tx.commit(); Group group = dao.find(1); group.setRemoteName("updateRemoteName"); group.setRemoteType("updateRemoteType"); group.setTitle("updateTitle"); dao.update(group); List<Group> find = dao.find(null, null, "updateRemoteName", "updateRemoteType"); assertNotNull(find); assertEquals(1, find.size()); Group result = find.get(0); assertEquals(group.getId(), result.getId()); assertEquals(group.getCreated(), result.getCreated()); assertEquals(group.getName(), result.getName()); assertEquals(group.getRemoteName(), result.getRemoteName()); assertEquals(group.getRemoteType(), result.getRemoteType()); assertEquals(group.getTimestamp(), result.getTimestamp()); assertEquals(group.getTitle(), result.getTitle()); }
@Override public void update(Group group) { DBRecord dbr = new DBRecord(); try { if (group.getId() == null) { dbr.create(table); final Timestamp now = new Timestamp(System.currentTimeMillis()); if (group.getCreated() == null) { group.setCreated(now); } group.setTimestamp(now); } else { dbr.read(table, new Object[] {group.getId()}, getConnection()); } dbr.setBeanValues(group); try { dbr.update(getConnection()); } catch (RecordUpdateInvalidException ex) { throw new ConcurrentModificationException(ex); } dbr.getBeanProperties(group); } finally { dbr.close(); } }
EmpireGroupDao extends EmpireDao implements GroupDao { @Override public void update(Group group) { DBRecord dbr = new DBRecord(); try { if (group.getId() == null) { dbr.create(table); final Timestamp now = new Timestamp(System.currentTimeMillis()); if (group.getCreated() == null) { group.setCreated(now); } group.setTimestamp(now); } else { dbr.read(table, new Object[] {group.getId()}, getConnection()); } dbr.setBeanValues(group); try { dbr.update(getConnection()); } catch (RecordUpdateInvalidException ex) { throw new ConcurrentModificationException(ex); } dbr.getBeanProperties(group); } finally { dbr.close(); } } }
EmpireGroupDao extends EmpireDao implements GroupDao { @Override public void update(Group group) { DBRecord dbr = new DBRecord(); try { if (group.getId() == null) { dbr.create(table); final Timestamp now = new Timestamp(System.currentTimeMillis()); if (group.getCreated() == null) { group.setCreated(now); } group.setTimestamp(now); } else { dbr.read(table, new Object[] {group.getId()}, getConnection()); } dbr.setBeanValues(group); try { dbr.update(getConnection()); } catch (RecordUpdateInvalidException ex) { throw new ConcurrentModificationException(ex); } dbr.getBeanProperties(group); } finally { dbr.close(); } } EmpireGroupDao(ProarcDatabase db); }
EmpireGroupDao extends EmpireDao implements GroupDao { @Override public void update(Group group) { DBRecord dbr = new DBRecord(); try { if (group.getId() == null) { dbr.create(table); final Timestamp now = new Timestamp(System.currentTimeMillis()); if (group.getCreated() == null) { group.setCreated(now); } group.setTimestamp(now); } else { dbr.read(table, new Object[] {group.getId()}, getConnection()); } dbr.setBeanValues(group); try { dbr.update(getConnection()); } catch (RecordUpdateInvalidException ex) { throw new ConcurrentModificationException(ex); } dbr.getBeanProperties(group); } finally { dbr.close(); } } EmpireGroupDao(ProarcDatabase db); @Override Group create(); @Override void update(Group group); @Override Group find(int id); @Override List<Group> find(Integer id, String grpName, String grpRemoteName, String grpRemoteType); }
EmpireGroupDao extends EmpireDao implements GroupDao { @Override public void update(Group group) { DBRecord dbr = new DBRecord(); try { if (group.getId() == null) { dbr.create(table); final Timestamp now = new Timestamp(System.currentTimeMillis()); if (group.getCreated() == null) { group.setCreated(now); } group.setTimestamp(now); } else { dbr.read(table, new Object[] {group.getId()}, getConnection()); } dbr.setBeanValues(group); try { dbr.update(getConnection()); } catch (RecordUpdateInvalidException ex) { throw new ConcurrentModificationException(ex); } dbr.getBeanProperties(group); } finally { dbr.close(); } } EmpireGroupDao(ProarcDatabase db); @Override Group create(); @Override void update(Group group); @Override Group find(int id); @Override List<Group> find(Integer id, String grpName, String grpRemoteName, String grpRemoteType);  }