Package org.apache.tuscany.das.rdb

Examples of org.apache.tuscany.das.rdb.DAS.createCommand()


        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();

        DataObject newBook = root.createDataObject("Book");
View Full Code Here


        // Using literals in the select forces invalid resultset metadata
        String sqlString = "Select 99, 'Roosevelt', '1600 Pennsylvania Avenue' from customer";

        DAS das = DAS.FACTORY.createDAS(getConnection());
        // Create and initialize command to read customers
        Command readCustomers = das.createCommand(sqlString);    

        // Read
        DataObject root = readCustomers.executeQuery();

        // Verify
View Full Code Here

    }

    public void testReadAndDelete() throws Exception {
        DAS das = DAS.FACTORY.createDAS(getConfig("OrdersOrderDetailsConfig.xml"), getConnection());
        Command getOrderDetails = das.createCommand("Select * from ORDERDETAILS where ORDERID = ? AND PRODUCTID = ?");

        getOrderDetails.setParameter(1, Integer.valueOf(1));
        getOrderDetails.setParameter(2, Integer.valueOf(1));

        DataObject root = getOrderDetails.executeQuery();
View Full Code Here

        ConfigHelper helper = new ConfigHelper(config);
        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]");
        // Change a field to mark the instance 'dirty'
        book.setInt("QUANTITY", 2);

View Full Code Here

     */
    public void testRead() throws Exception {

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

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

     */
    public void testReadSingle() throws Exception {

        // Create and initialize command to read customers
        DAS das = DAS.FACTORY.createDAS(getConnection());
        Command readCustomers = das.createCommand("select * from CUSTOMER where ID = 1");

        // Read
        DataObject root = readCustomers.executeQuery();

        // Verify
View Full Code Here

     */
    public void testReadSingle2() throws Exception {

        DAS das = DAS.FACTORY.createDAS(getConnection());
        // Create and initialize command to read customers
        Command readCustomers = das.createCommand("select * from CUSTOMER where ID = 1");

        // Read
        DataObject root = readCustomers.executeQuery();

        // Verify
View Full Code Here

     * Read a specific customer Same as above but tests tolerance of white space in provided SQL
     */
    public void testReadSingleWithWhiteSpace() throws Exception {
        DAS das = DAS.FACTORY.createDAS(getConnection());
        // Create and initialize command to read customers
        Command readCustomers = das.createCommand("   select * from CUSTOMER where ID = 1");

        // Read
        DataObject root = readCustomers.executeQuery();

        // Verify
View Full Code Here

     */
    public void testReadMultiple() throws Exception {

        DAS das = DAS.FACTORY.createDAS(getConnection());
        // Create and initialize command to read customers
        Command readCustomers = das.createCommand("select * from CUSTOMER where LASTNAME = 'Williams'");

        // Read
        DataObject root = readCustomers.executeQuery();

        // Verify
View Full Code Here

     * Read all customers with a specific last name LASTNAME value is provided via a parameter
     */
    public void testReadMultipleWithParameters() throws Exception {
        DAS das = DAS.FACTORY.createDAS(getConnection());
        // Create and initialize command to read customers
        Command readCustomers = das.createCommand("select * from CUSTOMER where LASTNAME = ?");

        // Parameterize the command
        readCustomers.setParameter(1, "Williams");
        DataObject root = readCustomers.executeQuery();

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.