@Test public void testFindForPid() 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(); Batch batch = dao.findForPid("uuid:4a7c2e50-af36-11dd-9643-000d606f5dc6"); assertNotNull(batch); }
@Override public Batch findForPid(String pid) { BatchItemTable tableItem = db.tableBatchItem; DBCommand cmd = db.createCommand(); cmd.select(table.getColumns()); cmd.join(table.id, tableItem.batchId); cmd.where(tableItem.pid.is(pid)); cmd.where(tableItem.type.is(BatchItem.Type.OBJECT)); cmd.where(tableItem.dsId.is(null)); DBReader reader = new DBReader(); try { reader.open(cmd, getConnection()); if (reader.moveNext()) { return getBeanProperties(reader); } else { return null; } } finally { reader.close(); } }
EmpireBatchDao extends EmpireDao implements BatchDao { @Override public Batch findForPid(String pid) { BatchItemTable tableItem = db.tableBatchItem; DBCommand cmd = db.createCommand(); cmd.select(table.getColumns()); cmd.join(table.id, tableItem.batchId); cmd.where(tableItem.pid.is(pid)); cmd.where(tableItem.type.is(BatchItem.Type.OBJECT)); cmd.where(tableItem.dsId.is(null)); DBReader reader = new DBReader(); try { reader.open(cmd, getConnection()); if (reader.moveNext()) { return getBeanProperties(reader); } else { return null; } } finally { reader.close(); } } }
EmpireBatchDao extends EmpireDao implements BatchDao { @Override public Batch findForPid(String pid) { BatchItemTable tableItem = db.tableBatchItem; DBCommand cmd = db.createCommand(); cmd.select(table.getColumns()); cmd.join(table.id, tableItem.batchId); cmd.where(tableItem.pid.is(pid)); cmd.where(tableItem.type.is(BatchItem.Type.OBJECT)); cmd.where(tableItem.dsId.is(null)); DBReader reader = new DBReader(); try { reader.open(cmd, getConnection()); if (reader.moveNext()) { return getBeanProperties(reader); } else { return null; } } finally { reader.close(); } } EmpireBatchDao(ProarcDatabase db); }
EmpireBatchDao extends EmpireDao implements BatchDao { @Override public Batch findForPid(String pid) { BatchItemTable tableItem = db.tableBatchItem; DBCommand cmd = db.createCommand(); cmd.select(table.getColumns()); cmd.join(table.id, tableItem.batchId); cmd.where(tableItem.pid.is(pid)); cmd.where(tableItem.type.is(BatchItem.Type.OBJECT)); cmd.where(tableItem.dsId.is(null)); DBReader reader = new DBReader(); try { reader.open(cmd, getConnection()); if (reader.moveNext()) { return getBeanProperties(reader); } else { return null; } } finally { reader.close(); } } 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 Batch findForPid(String pid) { BatchItemTable tableItem = db.tableBatchItem; DBCommand cmd = db.createCommand(); cmd.select(table.getColumns()); cmd.join(table.id, tableItem.batchId); cmd.where(tableItem.pid.is(pid)); cmd.where(tableItem.type.is(BatchItem.Type.OBJECT)); cmd.where(tableItem.dsId.is(null)); DBReader reader = new DBReader(); try { reader.open(cmd, getConnection()); if (reader.moveNext()) { return getBeanProperties(reader); } else { return null; } } finally { reader.close(); } } 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);  }