示例#1
0
  private void testSimpleUpdateWithCombinedPrimaryKey() {
    Order o = new Order();
    Order ourOrder = db.from(o).where(o.orderDate).is(valueOf("2007-01-02")).selectFirst();
    ourOrder.orderDate = valueOf("2007-01-03");
    db.update(ourOrder);

    Order ourUpdatedOrder = db.from(o).where(o.orderDate).is(valueOf("2007-01-03")).selectFirst();
    assertTrue("updated order not found", ourUpdatedOrder != null);

    // undo update
    ourOrder.orderDate = valueOf("2007-01-02");
    db.update(ourOrder);
  }
示例#2
0
  private void testSimpleUpdate() {
    Product p = new Product();
    Product pChang = db.from(p).where(p.productName).is("Chang").selectFirst();
    // update unitPrice from 19.0 to 19.5
    pChang.unitPrice = 19.5;
    // update unitsInStock from 17 to 16
    pChang.unitsInStock = 16;
    db.update(pChang);

    Product p2 = new Product();
    Product pChang2 = db.from(p2).where(p2.productName).is("Chang").selectFirst();
    assertEquals(19.5, pChang2.unitPrice);
    assertEquals(16, pChang2.unitsInStock.intValue());

    // undo update
    pChang.unitPrice = 19.0;
    pChang.unitsInStock = 17;
    db.update(pChang);
  }