Package org.apache.tuscany.das.rdb

Examples of org.apache.tuscany.das.rdb.Command.execute()


        assertFalse(root.get("CUSTOMER[1]/LASTNAME").equals("Pavick"));

        Command update = das.createCommand("update CUSTOMER set LASTNAME = ? where ID = ?");
        update.setParameter(1, "Pavick");
        update.setParameter(2, Integer.valueOf(1));
        update.execute();

        //Verify update - reuse select command
        root = select.executeQuery();
        assertEquals("Pavick", root.get("CUSTOMER[1]/LASTNAME"));
View Full Code Here


    public void testInsert() throws Exception {

        DAS das = DAS.FACTORY.createDAS(getConnection());
        Command insert = das.createCommand("insert into COMPANY (NAME) values (?)");
        insert.setParameter(1, "AAA Rental");
        insert.execute();

        // Verify insert
        // Verify
        Command select = das.createCommand("Select ID, NAME from COMPANY");
        DataObject root = select.executeQuery();
View Full Code Here

    public void testInsert2() throws Exception {

        DAS das = DAS.FACTORY.createDAS(getConnection());
        Command insert = das.createCommand("insert into COMPANY (NAME) values (?)");
        insert.setParameter(1, "AAA Rental");
        insert.execute();

        // insert another using same command
        insert.setParameter(1, "BBB Rental");
        insert.execute();
View Full Code Here

        insert.setParameter(1, "AAA Rental");
        insert.execute();

        // insert another using same command
        insert.setParameter(1, "BBB Rental");
        insert.execute();

        // Verify insert
        // Verify
        Command select = das.createCommand("Select ID, NAME from COMPANY");
        DataObject root = select.executeQuery();
View Full Code Here

    // Test ability to retrieve and utilize the generated key
    public void testInsert3() throws Exception {
        DAS das = DAS.FACTORY.createDAS(getConnection());
        Command insert = das.createCommand("insert into COMPANY (NAME) values (?)");
        insert.setParameter(1, "AAA Rental");
        insert.execute();
        //       Integer key = (Integer) insert.getParameterValue("generated_key");
        Integer key = (Integer) insert.getGeneratedKey();

        // Verify insert
        Command select = das.createCommand("Select ID, NAME from COMPANY where ID = ?");
View Full Code Here

      getDAS();
      Command select = das.createCommand("Select * from BOOK where BOOK_ID = 1");
        DataObject root = select.executeQuery();
        // Explicitly update the DB to force a collision
        Command update = das.createCommand("update BOOK set NAME = 'Puss in Hat' where BOOK_ID = 1");
        update.execute();
        DataObject book = root.getDataObject("BOOK[1]");

        // Modify customer
        book.set("NAME", "Puss in Bat");

View Full Code Here

            insertCommand.setParameter(paramIdx, origDataObject.get(currPropName));
            paramIdx++;
          }
        }
       
        insertCommand.execute();
       
        //there can be different possibilities
        //1- there is autogen key - insertCommand.getGeneratedKey() will return value and not exception
        //2- there is no autogen key - insertCommand.getGeneratedKey() will return exception and value needs to be taken from origDataObject
        //for 2 it is straight forward to know the column name same as property name
View Full Code Here

        config.setGeneratedKeysSupported("true");
       
        DAS das = DAS.FACTORY.createDAS(config, getConnection());
        Command insert = das.createCommand("insert into COMPANY (NAME) values (?)");
        insert.setParameter(1, "AAA Rental");
        insert.execute();
        Integer key = new Integer(insert.getGeneratedKey());
        // Verify insert
        Command select = das.createCommand("Select ID, NAME from COMPANY where ID = ?");
        select.setParameter(1, key);
        DataObject root = select.executeQuery();
View Full Code Here

        Config config = helper.getConfig();
     
        DAS das = DAS.FACTORY.createDAS(config, getConnection());
        Command insert = das.createCommand("insert into COMPANY (NAME) values (?)");
        insert.setParameter(1, "AAA Rental");
        insert.execute();
        Integer key = new Integer(insert.getGeneratedKey());
        // Verify insert
        Command select = das.createCommand("Select ID, NAME from COMPANY where ID = ?");
        select.setParameter(1, key);
        DataObject root = select.executeQuery();
View Full Code Here

        config.setGeneratedKeysSupported("false");

        DAS das = DAS.FACTORY.createDAS(config, getConnection());
        Command insert = das.createCommand("insert into COMPANY (NAME) values (?)");
        insert.setParameter(1, "AAA Rental");
        insert.execute();//this will happen as table is created with proper clause
               
        try{
          Integer key = new Integer(insert.getGeneratedKey());
          fail("Should not be able to retrieve key "+key);//unexpected
        }catch(RuntimeException e){
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.