Package org.apache.tuscany.das.rdb

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


        // Change a field to mark the instance 'dirty'
        book.setInt("QUANTITY", 2);

        // Flush the change
        // Create config programmatically
        ConfigHelper helper = new ConfigHelper();
        helper.addPrimaryKey("BOOK.BOOK_ID");

        ApplyChangesCommand apply = Command.FACTORY.createApplyChangesCommand(helper.getConfig());
        apply.setConnection(getConnection());

        apply.execute(root);

        // Verify
View Full Code Here


        String statement = "SELECT * FROM CUSTOMER LEFT JOIN ANORDER ON CUSTOMER.ID = ANORDER.CUSTOMER_ID WHERE CUSTOMER.ID = 1";

        // Read some customers and related orders
        // Create relationship config programmatically
        ConfigHelper helper = new ConfigHelper();
        helper.addRelationship("CUSTOMER.ID", "ANORDER.CUSTOMER_ID");
       
        Command select = Command.FACTORY.createCommand(statement, helper.getConfig());
        select.setConnection(getConnection());

        DataObject root = select.executeQuery();
        DataObject customer = root.getDataObject("CUSTOMER[1]");

View Full Code Here

    public void test_4() throws Exception {

        String statement = "SELECT * FROM BOOK WHERE BOOK.BOOK_ID = :ID";

        // Create Table config programmatically
        ConfigHelper helper = new ConfigHelper();
        helper.addTable("BOOK", "Book");
        helper.addPrimaryKey("Book.BOOK_ID");
       
        Command select = Command.FACTORY.createCommand(statement, helper.getConfig());
        select.setConnection(getConnection());
        select.setParameterValue("ID", new Integer(1));

        DataObject root = select.executeQuery();
       
        DataObject newBook = root.createDataObject("Book");
        newBook.setString("NAME", "Ant Colonies of the Old World");
        newBook.setInt("BOOK_ID", 1001);
        root.getList("Book").add(newBook);
              
        ApplyChangesCommand apply = Command.FACTORY.createApplyChangesCommand(helper.getConfig());
        apply.setConnection(getConnection());
        apply.execute(root);
       
        //Verify
        select.setParameterValue("ID", new Integer(1001));
View Full Code Here

    public void test_4() throws Exception {

        String statement = "SELECT * FROM BOOK WHERE BOOK.BOOK_ID = :ID";

        // Create Table config programmatically
        ConfigHelper helper = new ConfigHelper();
        helper.addTable("BOOK", "Book");
        helper.addPrimaryKey("BOOK.BOOK_ID");
       
        Command select = Command.FACTORY.createCommand(statement, helper.getConfig());
        select.setConnection(getConnection());
        select.setParameterValue("ID", new Integer(1));

        DataObject root = select.executeQuery();
       
        DataObject newBook = root.createDataObject("Book");
        newBook.setString("NAME", "Ant Colonies of the Old World");
        newBook.setInt("BOOK_ID", 1001);
        root.getList("Book").add(newBook);
              
        ApplyChangesCommand apply = Command.FACTORY.createApplyChangesCommand(helper.getConfig());
        apply.setConnection(getConnection());
        apply.execute(root);
       
        //Verify
        select.setParameterValue("ID", new Integer(1001));
View Full Code Here

     * the method for handling parameters was changed.
     */
    public void testReadModifyApply() throws Exception {

        // Provide updatecommand programmatically via config
        ConfigHelper helper = new ConfigHelper();
        Table customerTable = helper.addTable("CUSTOMER", "CUSTOMER");
        helper.addUpdateStatement(customerTable, "update CUSTOMER set LASTNAME = ? where ID = ?", "LASTNAME ID");

        DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());

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

View Full Code Here

     * Ensure that an implied relationship is not created when a defined one already exists
     *
     * @throws Exception
     */
    public void testRelationshipAlreadyDefined() throws Exception {
        ConfigHelper helper = new ConfigHelper();
        Relationship r = helper.addRelationship("CUSTOMER.ID", "ANORDER.CUSTOMER_ID");
        r.setName("definedRelationship");

        DAS das = DAS.FACTORY.createDAS(helper.getConfig(), 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]");
View Full Code Here

     * Read and modify a customer. Provide needed Create/Update/Delete statements programatically
     */
    public void testReadModifyApply() throws Exception {

        // Provide updatecommand programmatically via config
        ConfigHelper helper = new ConfigHelper();
        Table customerTable = helper.addTable("CUSTOMER", "CUSTOMER");
        helper.addUpdateStatement(customerTable, "update CUSTOMER set LASTNAME = ?, ADDRESS = ? "
                + "where ID = ?", "LASTNAME ADDRESS ID");

        DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());
        // Read customer 1
        Command select = das.createCommand("Select * from CUSTOMER where ID = 1");
        DataObject root = select.executeQuery();

        DataObject customer = (DataObject) root.get("CUSTOMER[1]");
View Full Code Here

     * Simple read followed by a write. Config instance is generated
     * programmatically using the ConfigHelper.
     */
    public void test2() throws Exception {
        // Create config programmatically
        ConfigHelper helper = new ConfigHelper();
        helper.addPrimaryKey("BOOK.BOOK_ID");
        DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());

        // Read a book instance
        Command select = das.createCommand("SELECT * FROM BOOK WHERE BOOK_ID = 1");
        DataObject root = select.executeQuery();
        DataObject book = root.getDataObject("BOOK[1]");
View Full Code Here

        String statement = "SELECT * FROM CUSTOMER LEFT JOIN ANORDER ON CUSTOMER.ID = ANORDER.CUSTOMER_ID "
                + "WHERE CUSTOMER.ID = 1";

        // Read some customers and related orders
        // Create relationship config programmatically
        ConfigHelper helper = new ConfigHelper();
        helper.addRelationship("CUSTOMER.ID", "ANORDER.CUSTOMER_ID");
        DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());
        Command select = das.createCommand(statement);

        DataObject root = select.executeQuery();
        DataObject customer = root.getDataObject("CUSTOMER[1]");

View Full Code Here

    public void test4() throws Exception {

        String statement = "SELECT * FROM BOOK WHERE BOOK.BOOK_ID = ?";

        // Create Table config programmatically
        ConfigHelper helper = new ConfigHelper();
        helper.addTable("BOOK", "Book");
        helper.addPrimaryKey("Book.BOOK_ID");

        DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());
        Command select = das.createCommand(statement);
        select.setParameter(1, Integer.valueOf(1));

        DataObject root = select.executeQuery();

View Full Code Here

TOP

Related Classes of org.apache.tuscany.das.rdb.ConfigHelper

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.