Examples of DAS


Examples of org.apache.tuscany.das.rdb.DAS

     * Add a new Order to a list of Customers without defining any config information
     *
     * @throws Exception
     */
    public void testAddNewOrder() throws Exception {
        DAS das = DAS.FACTORY.createDAS(getConnection());

        Command select = das.createCommand("SELECT * FROM CUSTOMER LEFT JOIN ANORDER "
                + "ON CUSTOMER.ID = ANORDER.CUSTOMER_ID");

        DataObject root = select.executeQuery();

        DataObject cust = root.getDataObject("CUSTOMER[1]");

        // Save ID and Order Count
        int custID = cust.getInt("ID");
        int custOrderCount = cust.getList("ANORDER").size();

        // Create a new Order and add to customer1
        DataObject order = root.createDataObject("ANORDER");

        order.set("ID", Integer.valueOf(99));
        order.set("PRODUCT", "The 99th product");
        order.set("QUANTITY", Integer.valueOf(99));
        cust.getList("ANORDER").add(order);

        assertEquals(custOrderCount + 1, cust.getList("ANORDER").size());

        // Build apply changes command
        das.applyChanges(root);

        // verify cust1 relationship updates
        select = das.createCommand("SELECT * FROM CUSTOMER LEFT JOIN ANORDER ON CUSTOMER.ID = ANORDER.CUSTOMER_ID "
                 + "where CUSTOMER.ID = ?");

        select.setParameter(1, Integer.valueOf(custID));
        root = select.executeQuery();

View Full Code Here

Examples of org.apache.tuscany.das.rdb.DAS

    protected void tearDown() throws Exception {
        super.tearDown();
    }

    public void testMultipleResultSets() throws Exception {
        DAS das = DAS.FACTORY.createDAS(getConnection());
        Command read = das.createCommand("{call GETALLCUSTOMERSANDORDERS()}");

        DataObject root = read.executeQuery();

        // Verify
        assertEquals(5, root.getList("CUSTOMER").size());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.