コード例 #1
0
  public void testChanged() throws Exception {

    Order po = OrderMother.makeOrder();
    save(po.getRestaurant());
    save(po);
    final Serializable orderId = po.getId();

    Order detachedOrder = am.detach(po);

    doWithTransaction(
        new TxnCallback() {
          public void execute() throws Exception {
            Order po = (Order) load(Order.class, orderId.toString());
            po.noteSent("msgid", new Date());
            po.accept("x");
          }
        });

    try {
      Order attachedOrder = am.attach(detachedOrder);
      fail("Expected exception");
    } catch (OptimisticLockingFailureException e) {

    }
  }
コード例 #2
0
  public void test() throws Exception {

    Order po = OrderMother.makeOrder();
    save(po.getRestaurant());
    save(po);

    Order detachedOrder = am.detach(po);
    detachedOrder.getVersion();
    detachedOrder.noteSent("msgid", new Date());
    detachedOrder.accept("x");

    Order attachedOrder = am.attach(detachedOrder);
    assertFalse(attachedOrder.isAcknowledgable());
  }