Package commonj.sdo

Examples of commonj.sdo.DataObject


    public void testReadModifyApplyWithAssumedIDFailure3() throws Exception {
     
    Command select = Command.FACTORY
        .createCommand("Select * from ORDERDETAILS");
    select.setConnection(getConnection());
    DataObject root = select.executeQuery();

    DataObject od = root.createDataObject("ORDERDETAILS");

    //Modify customer
    od.setInt("PRODUCTID", 72)
    od.setInt("ORDERID", 500);
   
    //Build apply changes command
    ApplyChangesCommand apply = Command.FACTORY.createApplyChangesCommand();
    apply.setConnection(getConnection());   

View Full Code Here


  }
    private DataObject getCustomerByLastName(DataObject root, String name) {
      Iterator i = root.getList("CUSTOMER").iterator();
      while ( i. hasNext()) {
        DataObject obj = (DataObject)i.next();
        if (name.equals(obj.getString("LASTNAME")))
          return obj;
      }
      return null;
    }
View Full Code Here

    Command select = Command.FACTORY
        .createCommand(
            "Select * from STATES inner join CITIES on STATES.ID = CITIES.STATE_ID",
            getConfig("cityStates.xml"));
    select.setConnection(getConnection());
    DataObject root = select.executeQuery();

    int numberOfStates = root.getList("STATES").size();
    int numberOfCities = root.getList("CITIES").size();

    DataObject atlanta = root.createDataObject("CITIES");
    atlanta.setString("NAME", "Atlanta");
    atlanta.setInt("ID", 6);

    // Create a new Company
    DataObject georgia = root.createDataObject("STATES");
    georgia.setInt("ID", 4);
    georgia.setString("NAME", "GA");

    georgia.getList("cities").add(atlanta);

    // Create apply command
    ApplyChangesCommand apply = Command.FACTORY.createApplyChangesCommand(getConfig("cityStates.xml"));
    apply.setConnection(getConnection());

View Full Code Here

        // Verify insert
        // Verify
        Command select = Command.FACTORY.createCommand("Select ID, NAME from COMPANY");
        select.setConnection(getConnection());
        DataObject root = select.executeQuery();

        assertEquals(4, root.getList("COMPANY").size());
        assertTrue(root.getInt("COMPANY[1]/ID") > 0);

    }
View Full Code Here

        // Verify insert
        // Verify
        Command select = Command.FACTORY.createCommand("Select ID, NAME from COMPANY");
        select.setConnection(getConnection());
        DataObject root = select.executeQuery();

        assertEquals(5, root.getList("COMPANY").size());

    }
View Full Code Here

        // Verify insert
        Command select = Command.FACTORY.createCommand("Select ID, NAME from COMPANY where ID = :ID");
        select.setConnection(getConnection());
        select.setParameterValue("ID", key);
        DataObject root = select.executeQuery();
        assertEquals(key, root.get("COMPANY[1]/ID"));

    }
View Full Code Here

    // Test ability to propogate generated values back to owning data objects
    public void testPropagateIds() throws Exception {

        Command select = Command.FACTORY.createCommand("Select * from COMPANY");
        select.setConnection(getConnection());
        DataObject root = select.executeQuery();

        // Create a new Company
        DataObject company = root.createDataObject("COMPANY");
        company.setString("NAME", "Do-rite Pest Control");

        // Create apply command
        ApplyChangesCommand apply = Command.FACTORY.createApplyChangesCommand(getConfig("CompanyConfig.xml"));
        apply.setConnection(getConnection());

        // verify pre-condition (id is not there until after flush)
        assertNull(company.get("ID"));

        // Flush changes
        apply.execute(root);

        // Save the id
        Integer id = (Integer) company.get("ID");

        // Verify the change
        select = Command.FACTORY.createCommand("Select * from COMPANY where ID = :ID");
        select.setConnection(getConnection());
        select.setParameterValue("ID", id);
View Full Code Here

    public void testPropagateIdsXML() throws Exception {

        Command select = Command.FACTORY.createCommand("Select * from COMPANY",
                getConfig("basicCompanyMapping.xml"));
        select.setConnection(getConnection());
        DataObject root = select.executeQuery();

        // Create a new Company
        DataObject company = root.createDataObject("COMPANY");
        company.setString("NAME", "Do-rite Pest Control");

        // Create apply command
        ApplyChangesCommand apply = Command.FACTORY
                .createApplyChangesCommand(getConfig("basicCompanyMapping.xml"));
        apply.setConnection(getConnection());

        // verify pre-condition (id is not there until after flush)
        assertNull(company.get("ID"));

        // Flush changes
        apply.execute(root);

        // Save the id
        Integer id = (Integer) company.get("ID");

        // Verify the change
        select = Command.FACTORY.createCommand("Select * from COMPANY where ID = :ID");
        select.setConnection(getConnection());
        select.setParameterValue("ID", id);
View Full Code Here

        String selectCompanys = "SELECT * FROM COMPANY LEFT JOIN DEPARTMENT ON COMPANY.ID = DEPARTMENT.COMPANYID";

        Command select = Command.FACTORY.createCommand(selectCompanys,
                getConfig("basicCompanyDepartmentMapping.xml"));
        select.setConnection(getConnection());
        DataObject root = select.executeQuery();

        // Create a new Company
        DataObject company = root.createDataObject("COMPANY");
        company.setString("NAME", "Do-rite Pest Control");

        // Create a new Department
        // Do not set ID or CompanyID since these are generated
        // ID INT, NAME VARCHAR(30), LOCATION VARCHAR(30), NUMBER VARCHAR(10),
        // COMPANYID INT, EOTM INT
        DataObject department = root.createDataObject("DEPARTMENT");
        department.setString("NAME", "Do-rite Pest Control");
        department.setString("LOCATION", "The boonies");
        department.setString("NUMBER", "101");

        // Associate the new department with the new company
        company.getList("departments").add(department);

        // Create apply command
View Full Code Here

        String selectCompanys = "SELECT * FROM COMPANY LEFT JOIN DEPARTMENT ON COMPANY.ID = DEPARTMENT.COMPANYID";

        Command select = Command.FACTORY.createCommand(selectCompanys,
                getConfig("basicCompanyDepartmentMapping.xml"));
        select.setConnection(getConnection());
        DataObject root = select.executeQuery();

        // Create a new Company
        DataObject company = root.createDataObject("COMPANY");
        company.setString("NAME", "Do-rite Pest Control");

        // Create a new Department
        // Do not set ID or CompanyID since these are generated
        // ID INT, NAME VARCHAR(30), LOCATION VARCHAR(30), NUMBER VARCHAR(10),
        // COMPANYID INT, EOTM INT
        DataObject department = root.createDataObject("DEPARTMENT");
        department.setString("NAME", "Do-rite Pest Control");
        // Do not set this property to force storing NULL to DB
        // department.setString("LOCATION", "The boonies");
        department.setString("NUMBER", "101");

        // Associate the new department with the new company
        company.getList("departments").add(department);

        // Create apply command
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.