Package commonj.sdo

Examples of commonj.sdo.DataObject


    public void testUpdate() throws Exception {

        CommandGroup commandGroup = CommandGroup.FACTORY.createCommandGroup(getConfig("CustOrdersConnectionProps.xml"));

        Command read = commandGroup.getCommand("all customers");
        DataObject root = read.executeQuery();
        // Verify precondition
        assertFalse(root.get("CUSTOMER[1]/LASTNAME").equals("Pavick"));
        int id = root.getInt("CUSTOMER[1]/ID");

        Command update = commandGroup.getCommand("update customer");
        update.setParameterValue("ID", new Integer(id));
        update.execute();

        // Verify update - reuse select command
        root = read.executeQuery();
        assertEquals("Pavick", root.get("CUSTOMER[1]/LASTNAME"));

    }
View Full Code Here


        CommandGroup commandGroup = CommandGroup.FACTORY.createCommandGroup(getConfig("CustomersOrdersConfig.xml"));
        commandGroup.setConnection(getConnection());

        // Read all customers and remember the first one
        Command read = commandGroup.getCommand("all customers");
        DataObject root = read.executeQuery();
        Integer id = (Integer) root.get("CUSTOMER[1]/ID");

        // Read the specific Customer from above and its related orders
        Command custOrders = commandGroup.getCommand("customer and orders");
        custOrders.setParameterValue("ID", id);
        root = custOrders.executeQuery();

        // Modify the first order and flush this change back to the database
        root.setString("CUSTOMER[1]/orders[1]/PRODUCT", "Defibrillator");
        Integer orderId = (Integer) root.get("CUSTOMER[1]/orders[1]/ID");
        ApplyChangesCommand flush = commandGroup.getApplyChangesCommand();
        flush.execute(root);

        // Verify
        Command orderByID = commandGroup.getCommand("order by id");
        orderByID.setParameterValue("ID", orderId);
        assertEquals("Defibrillator", root.getString("ANORDER[1]/PRODUCT"));

    }
View Full Code Here

        readCustomers.setResultSetShape(shape);

        readCustomers.setConnection(getConnection());

        // Read
        DataObject root = readCustomers.executeQuery();

        // Verify
        assertEquals(5, root.getList("CUSTOMER").size());
        assertEquals(99, root.getInt("CUSTOMER[1]/ID"));
        assertEquals("Roosevelt", root.getString("CUSTOMER[1]/LASTNAME"));
        assertEquals("1600 Pennsylvania Avenue", root.getString("CUSTOMER[1]/ADDRESS"));

    }
View Full Code Here

        // Create and initialize command to read customers
        Command readCustomers = Command.FACTORY.createCommand(sqlString);
        readCustomers.setConnection(getConnection());

        // Read
        DataObject root = readCustomers.executeQuery();

        // Verify
        try {
            assertEquals(5, root.getList("CUSTOMER").size());
            fail("Should fail since there will be no feature named CUSTOMER");
        } catch (IllegalArgumentException e) {
            // OK
        }
View Full Code Here

  public void testRead() throws Exception {

    //Read customer 1
    Command select = Command.FACTORY.createCommand("Select * from TYPETEST where ID = 1")
    select.setConnection(getConnection());
    DataObject root = select.executeQuery();
   
    DataObject types = (DataObject)root.get("TYPETEST[1]");
   
    java.sql.Timestamp ts = (java.sql.Timestamp)types.get("ATIMESTAMP");
    assertEquals(ts, TypesData.getTimestamp());
   
    float decimal = types.getFloat("ADECIMAL");
    assertEquals(1234567.89f, decimal, .0001);

  }
View Full Code Here

  public void testReadCustomers() throws Exception {
    ReadCustomersCommand cmd = new ReadCustomersCommand();
    cmd.setConnection(getConnection());

    DataObject root = cmd.executeQuery();
    assertEquals(5, root.getList("CUSTOMER").size());
  }
View Full Code Here

  public void testReadSomeCustomers() throws Exception {
    ReadCustomersByLastnameCommand cmd = new ReadCustomersByLastnameCommand();
    cmd.setConnection(getConnection());
    cmd.setParameterValue("LASTNAME", "Williams");

    DataObject root = cmd.executeQuery();
    assertEquals(4, root.getList("CUSTOMER").size());

  }
View Full Code Here

  }
 
  public void testSimpleReadCustomersWithShape() throws Exception {
    SimpleReadCustomersWithShapeCommand cmd = new SimpleReadCustomersWithShapeCommand();
    cmd.setConnection(getConnection());   
    DataObject root = cmd.executeQuery();
    assertEquals(5, root.getList("CUSTOMER").size());
  }
View Full Code Here

 
  public void testReadCustomersOrdersWithShape() throws Exception {
    ReadCustomersWithShapeCommand cmd = new ReadCustomersWithShapeCommand();
    cmd.setConnection(getConnection());
   
    DataObject root = cmd.executeQuery();
    assertEquals(5, root.getList("CUSTOMER").size());
  }
View Full Code Here

        CommandGroup commandGroup = CommandGroup.FACTORY.createCommandGroup(createConfigStream());
        commandGroup.setConnection(createConnection());
        Command read = commandGroup.getCommand("all stocks");

        DataObject root = read.executeQuery();

        // Create a new stockPurchase
        DataObject stockPurchase = root.createDataObject("STOCKS");
        stockPurchase.set("ID", new Integer(sp.getId()));
        stockPurchase.set("SYMBOL", sp.getStock().getSymbol());
        stockPurchase.set("QUANTITY", new Integer(sp.getStock().getQuantity()));
        stockPurchase.set("PURCHASEPRICE", new Float(11.00));
        stockPurchase.set("PURCHASEDATE", new Date());

        ApplyChangesCommand apply = commandGroup.getApplyChangesCommand();

        apply.execute(root);
View Full Code Here

TOP

Related Classes of commonj.sdo.DataObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.