Esempio n. 1
0
 /**
  * データを再読み込みします。
  *
  * @param row 元の行
  * @param newRow 新しい行
  */
 protected void reload(DataRow row, DataRow newRow) {
   SelectHandler selectHandler =
       new BasicSelectHandler(dataSource, sql, new DataRowReloadResultSetHandler(newRow));
   Object[] args = new Object[primaryKeys.length];
   for (int i = 0; i < primaryKeys.length; ++i) {
     args[i] = row.getValue(primaryKeys[i]);
   }
   selectHandler.execute(args);
 }
 /** @throws Exception */
 public void testHandle2() throws Exception {
   String sql = "select dept_no, d_name from dept3 where dept_no = ?";
   DataTable table = new DataTableImpl("dept3");
   table.addColumn("dept_no").setPrimaryKey(true);
   table.addColumn("d_name");
   DataRow row = table.addRow();
   row.setValue("dept_no", new BigDecimal(20));
   row.setValue("d_name", "RESEARCH");
   DataTable newTable = new DataTableImpl("dept3");
   newTable.addColumn("dept_no").setPrimaryKey(true);
   newTable.addColumn("d_name");
   DataRow newRow = newTable.addRow();
   SelectHandler handler =
       new BasicSelectHandler(ds_, sql, new DataRowReloadResultSetHandler(newRow));
   handler.execute(new Object[] {new Integer(20)});
   System.out.println(newRow);
   assertEquals(row, newRow);
 }
 /** @throws Exception */
 public void testHandle() throws Exception {
   String sql = "select empno, ename from emp where empno = ?";
   DataTable table = new DataTableImpl("emp");
   table.addColumn("empno").setPrimaryKey(true);
   table.addColumn("ename");
   DataRow row = table.addRow();
   row.setValue("empno", new BigDecimal(7788));
   row.setValue("ename", "SCOTT");
   DataTable newTable = new DataTableImpl("emp");
   newTable.addColumn("empno").setPrimaryKey(true);
   newTable.addColumn("ename");
   DataRow newRow = newTable.addRow();
   SelectHandler handler =
       new BasicSelectHandler(ds_, sql, new DataRowReloadResultSetHandler(newRow));
   handler.execute(new Object[] {new Integer(7788)});
   System.out.println(newRow);
   assertEquals("2", row, newRow);
 }