Package commonj.sdo

Examples of commonj.sdo.DataObject


   
    Command select = Command.FACTORY
        .createCommand("Select ID, LASTNAME, ADDRESS from CUSTOMER where ID <= :ID");
    select.setConnection(getConnection());
    select.setParameterValue("ID", "3");
    DataObject graph1 = select.executeQuery();
    assertEquals(3, graph1.getList("CUSTOMER").size());

    select.setParameterValue("ID", "5");
    DataObject graph2 = select.executeQuery();
    assertEquals(5, graph2.getList("CUSTOMER").size());

    GraphMerger merger = new GraphMerger();
    merger.addPrimaryKey("CUSTOMER.ID");
    DataObject mergedGraph = merger.merge(graph1, graph2);

    assertEquals(5, mergedGraph.getList("CUSTOMER").size());
  }
View Full Code Here


    Command select = Command.FACTORY
        .createCommand("Select ID, LASTNAME, ADDRESS from CUSTOMER where ID <= :ID");
    select.setConnection(getConnection());
    select.setParameterValue("ID", "3");
    DataObject graph1 = select.executeQuery();
    assertEquals(3, graph1.getList("CUSTOMER").size());

    select.setParameterValue("ID", "4");
    DataObject graph2 = select.executeQuery();
    assertEquals(4, graph2.getList("CUSTOMER").size());

    select.setParameterValue("ID", "5");
    DataObject graph3 = select.executeQuery();
    assertEquals(5, graph3.getList("CUSTOMER").size());

    GraphMerger merger = new GraphMerger();
    merger.addPrimaryKey("CUSTOMER.ID");
    ArrayList graphs = new ArrayList();
    graphs.add(graph1);
    graphs.add(graph2);
    graphs.add(graph3);
    DataObject mergedGraph = merger.merge(graphs);

    assertEquals(5, mergedGraph.getList("CUSTOMER").size());

  }
View Full Code Here

                "SELECT * FROM CUSTOMER LEFT JOIN ANORDER ON CUSTOMER.ID = ANORDER.CUSTOMER_ID where CUSTOMER.ID = :ID", getConfig("CustomersOrdersConfig.xml"))
        select.setConnection(getConnection());
       
        select.setConnection(getConnection());
        select.setParameterValue("ID", new Integer(1));
        DataObject graph1 = select.executeQuery();
       
        DataObject customer = (DataObject)graph1.getList("CUSTOMER").get(0);
        assertEquals(2, customer.getList("orders").size());   
       
        select.setParameterValue("ID", new Integer(2));
        DataObject graph2 = select.executeQuery();
        DataObject customer2 = (DataObject)graph2.getList("CUSTOMER").get(0);
        assertEquals(1, graph2.getList("CUSTOMER").size());
        assertEquals(1, customer2.getList("orders").size());
        assertEquals(2, customer2.getInt("ID"));
       
        GraphMerger merger = new GraphMerger();
        merger.addPrimaryKey("CUSTOMER.ID");
        merger.addPrimaryKey("ANORDER.ID");
        DataObject mergedGraph = merger.merge(graph1, graph2);
       
        assertEquals(3, mergedGraph.getList("ANORDER").size());
        assertEquals(2, mergedGraph.getList("CUSTOMER").size());
       
        DataObject mergedCustomer = (DataObject) mergedGraph.getList("CUSTOMER").get(1);
        assertEquals(2, mergedCustomer.getInt("ID"));
        assertEquals(1, mergedCustomer.getList("orders").size());
        DataObject mergedOrder = (DataObject) mergedCustomer.getList("orders").get(0);
        assertEquals(4, mergedOrder.getInt("ID"));
       
    }
View Full Code Here

                "SELECT * FROM CUSTOMER LEFT JOIN ANORDER ON CUSTOMER.ID = ANORDER.CUSTOMER_ID where CUSTOMER.ID = :ID", getConfig("CustomersOrdersConfig.xml"))
        select.setConnection(getConnection());
       
        select.setConnection(getConnection());
        select.setParameterValue("ID", new Integer(1));
        DataObject graph1 = select.executeQuery();
       
        DataObject customer = (DataObject)graph1.getList("CUSTOMER").get(0);
        assertEquals(2, customer.getList("orders").size());
       
        Command select2 = Command.FACTORY.createCommand("select * from ANORDER");
        select2.setConnection(getConnection());
        DataObject graph2 = select2.executeQuery();
        assertEquals(4, graph2.getList("ANORDER").size());
       
        GraphMerger merger = new GraphMerger();
        merger.addPrimaryKey("CUSTOMER.ID");
        merger.addPrimaryKey("ANORDER.ID");
        DataObject mergedGraph = merger.merge(graph1, graph2);
        assertEquals(4, mergedGraph.getList("ANORDER").size());
        assertEquals(1, mergedGraph.getList("CUSTOMER").size());
    }
View Full Code Here

        // Parameterize the command
        selectCommand.setConnection(getConnection());

        // Get the graph
        DataObject root = selectCommand.executeQuery();

        // Get a company
        DataObject company = (DataObject) root.getList("CompanyType").get(0);
        assertEquals("MegaCorp", company.get("NAME"));

        // Get a department
        DataObject department = (DataObject) company.getList("departments").get(0);
        assertEquals("Advanced Technologies", department.get("NAME"));

        DataObject employee = (DataObject) department.getList("employees").get(0);
        assertEquals("John Jones", employee.get("NAME"));
    }
View Full Code Here

    // Read customer with particular ID
    Command select = Command.FACTORY
        .createCommand("Select * from CUSTOMER where ID = 1");
    select.setConnection(getConnection());
    DataObject root = select.executeQuery();

    DataObject customer = (DataObject) root.get("CUSTOMER[1]");

    // Modify customer
    customer.set("LASTNAME", "Pavick");

    // Build apply changes command
    ApplyChangesCommand apply = Command.FACTORY
        .createApplyChangesCommand(getConfig("basicCustomerMappingWithInvalidCUD.xml"));
    apply.setConnection(getConnection());
View Full Code Here

  public void testInsertCUDGeneration() throws Exception {
    Command select = Command.FACTORY
        .createCommand("Select * from CUSTOMER where ID = 1");
    select.setConnection(getConnection());
    DataObject root = select.executeQuery();

    DataObject customer = root.createDataObject("CUSTOMER");
    customer.setInt("ID", 720);
    customer.set("LASTNAME", "foobar");
    customer.set("ADDRESS", "asdfasdf");

    ApplyChangesCommand apply = Command.FACTORY.createApplyChangesCommand();
    apply.setConnection(getConnection());
    apply.execute(root);

View Full Code Here

    // Parameterize the command
    select.setConnection(getConnection());
    select.setParameterValue("ID", new Integer(1));

    // Get the graph
    DataObject root = select.executeQuery();

    // Modify a customer
    DataObject customer = (DataObject) root.get("Customer[1]");
    customer.set("LASTNAME", "Pavick");

    // Modify an order
    DataObject order = (DataObject) customer.get("orders[1]");
    order.setString("PRODUCT", "Kitchen Sink 001");

    ApplyChangesCommand apply = Command.FACTORY.createApplyChangesCommand(getConfig("1xM_mapping_no_cud.xml"));
    apply.setConnection(getConnection());   

    // Flush changes
View Full Code Here

    // Read a customer
    Command select = Command.FACTORY.createCommand(
        "SELECT * FROM CUSTOMER WHERE CUSTOMER.ID = 1", getConfig("customerMapping.xml"));
    select.setConnection(getConnection());

    DataObject root = select.executeQuery();
    DataObject customer = root.getDataObject("Customer[1]");
    assertEquals(1, customer.getInt("id"));
    assertEquals("1212 foobar lane", customer.getString("address"));
    assertEquals("Williams", customer.getString("lastname"));
   
  }
View Full Code Here

        try {

            // Read customer 1
            Command select = Command.FACTORY.createCommand("Select * from CUSTOMER where ID = 1");
            select.setConnection(c);
            DataObject root = select.executeQuery();

            DataObject customer = (DataObject) root.get("CUSTOMER[1]");

            // Modify customer
            customer.set("LASTNAME", "Pavick");

            // Build apply changes command
            ApplyChangesCommand apply = Command.FACTORY.createApplyChangesCommand();
            apply.setConnection(c, false);

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.