Package commonj.sdo

Examples of commonj.sdo.DataObject


        getOrderDetails.setConnection(getConnection());

        getOrderDetails.setParameterValue("ORDERID", new Integer(1));
        getOrderDetails.setParameterValue("PRODUCTID", new Integer(1));

        DataObject root = getOrderDetails.executeQuery();

        DataObject orderDetail = (DataObject) root.get("ORDERDETAILS[1]");
        assertEquals(1.1f, orderDetail.getFloat("PRICE"), 0.01);

    }
View Full Code Here


    public void testReadModifyWrite2() throws Exception {

        Command getOrderDetails = Command.FACTORY
                .createCommand("Select * from ORDERDETAILS where ORDERID = 1 AND PRODUCTID = 1");
        getOrderDetails.setConnection(getConnection());
        DataObject root = getOrderDetails.executeQuery();

        DataObject orderDetails = (DataObject) root.get("ORDERDETAILS[1]");
        assertEquals(1.1f, orderDetails.getFloat("PRICE"), 0.01);

        // Modify
        orderDetails.setFloat("PRICE", 0f);

        // Build apply changes command
        ApplyChangesCommand apply = Command.FACTORY.createApplyChangesCommand(getConfig("OrdersOrderDetailsConfig.xml"));
        apply.setConnection(getConnection());

        // Write
        apply.execute(root);

        // Verify
        root = getOrderDetails.executeQuery();
        orderDetails = root.getDataObject("ORDERDETAILS[1]");
        assertEquals(0f, orderDetails.getFloat("PRICE"), 0.01);

    }
View Full Code Here

        Command read = Command.FACTORY
                .createCommand("SELECT * FROM ANORDER LEFT JOIN ORDERDETAILS ON ANORDER.ID = ORDERDETAILS.ORDERID ORDER BY ANORDER.ID", getConfig("OrdersOrderDetailsConfig.xml"));
        read.setConnection(getConnection());

        DataObject root = read.executeQuery();

        DataObject firstOrder = root.getDataObject("ANORDER[1]");
        assertEquals(1, firstOrder.getInt("ID"));
        assertEquals(2, firstOrder.getList("ORDERDETAILS").size());

    }
View Full Code Here

  public void testSimpleOCC() throws Exception {
   
    //Read a book instance
    Command select = Command.FACTORY.createCommand("SELECT * FROM BOOK WHERE BOOK_ID = 1");
    select.setConnection(getConnection());
    DataObject root = select.executeQuery();
    DataObject book = root.getDataObject("BOOK[1]");
    //Change a field to mark the instance 'dirty'
    book.setInt("QUANTITY", 2);

    // Explicitly change OCC column in database to force collision
    Command update = Command.FACTORY
        .createCommand("update BOOK set OCC = :OCC where BOOK_ID = 1");
    update.setConnection(getConnection());
View Full Code Here

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

        Command read = commandGroup.getCommand("get companies with employee of the month");
        DataObject root = read.executeQuery();
        DataObject employee = root.getDataObject("COMPANY[1]/company->employee_opposite");

        assertEquals("Mary Smith", employee.getString("NAME"));
    }
View Full Code Here

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

        Command read = commandGroup.getCommand("get named employee with company");
        read.setParameterValue("NAME", "Mary Smith");
        DataObject root = read.executeQuery();
        DataObject company = root.getDataObject("EMPLOYEE[1]/company->employee");

        assertEquals("ACME Publishing", company.getString("NAME"));
    }
View Full Code Here

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

        Command read = commandGroup.getCommand("get companies with employee of the month");
        DataObject root = read.executeQuery();
        DataObject company = root.getDataObject("COMPANY[1]");
        company.setDataObject("company->employee_opposite", null);
        assertNull(company.getDataObject("company->employee_opposite"));
  
        //Flush changes
        commandGroup.getApplyChangesCommand().execute(root);

        //Verify
        root = read.executeQuery();
        company = root.getDataObject("COMPANY[1]");
        assertNull(company.getDataObject("company->employee_opposite"));
    }
View Full Code Here

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

        Command read = commandGroup.getCommand("get companies with employee of the month");
        DataObject root = read.executeQuery();
        DataObject company = root.getDataObject("COMPANY[1]");
        DataObject employee = company.getDataObject("company->employee_opposite");
        employee.delete();
        assertNull(company.getDataObject("company->employee_opposite"));
  
        //Flush changes
        commandGroup.getApplyChangesCommand().execute(root);
View Full Code Here

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

        Command read = commandGroup.getCommand("get companies with employee of the month");
        DataObject root = read.executeQuery();
        DataObject company = root.getDataObject("COMPANY[1]");
       
        //Create a new employee
        DataObject employee = root.createDataObject("EMPLOYEE");
        employee.setString ("NAME", "Joe Hotshot");
       
      //Assigne a EOTM
        //Strangely this statement results in "Could not find relationships" error
        //although "company.setDataObject("company->employee_opposite", null);" dos not  
        company.setDataObject("company->employee_opposite", employee);    
        
        //Flush changes
        commandGroup.getApplyChangesCommand().execute(root);

        //Verify
        root = read.executeQuery();
        company = root.getDataObject("COMPANY[1]");
       
        employee = root.getDataObject("COMPANY[1]/company->employee_opposite");

        assertEquals("Joe Hotshot", employee.getString("NAME"));
       
    }
View Full Code Here

    Type[] types = { SDODataTypes.INTEGEROBJECT, SDODataTypes.DATE, SDODataTypes.STRING };
    ResultSetShape shape = new ResultSetShape(tables, columns, types);
    read.setResultSetShape(shape);
           
    //Read
    DataObject root = read.executeQuery();
   
    //Verify
    assertEquals(kbday, root.getDate("CUSTOMER[1]/LASTNAME"));
   
    //Modify
    root.setDate("CUSTOMER[1]/LASTNAME", tbday)
   
    ApplyChangesCommand write = Command.FACTORY.createApplyChangesCommand(getConfig("CustomerConfigWithConverter.xml"));
    write.setConnection(getConnection());
    write.execute(root);
   
    //Read
    root = read.executeQuery();

    //Verify
    assertEquals(tbday, root.getDate("CUSTOMER[1]/LASTNAME"));
   
  }
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.