Package org.apache.tuscany.das.rdb.config

Examples of org.apache.tuscany.das.rdb.config.Table


     */
    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
View Full Code Here


        if (!rel.isMany()) {
            if (rel.isKeyRestricted()) {
                throw new RuntimeException("Can not modify a one to one relationship that is key restricted");
            }
            // This is a one-one relationship
            Table t = mapping.getTableByTypeName(changedObject.getType().getName());
            TableWrapper tw = new TableWrapper(t);
            RelationshipWrapper rw = new RelationshipWrapper(rel);
            if ((rel.getForeignKeyTable().equals(t.getTableName()))
                    && (Collections.disjoint(tw.getPrimaryKeyProperties(), rw.getForeignKeys()))) {
                return true;
            }

        }
View Full Code Here

            return;
        }

        Iterator i = mapping.getConfig().getTable().iterator();
        while (i.hasNext()) {
            Table t = (Table) i.next();
            Iterator columns = t.getColumn().iterator();
            while (columns.hasNext()) {
                Column c = (Column) columns.next();
                if (c.isPrimaryKey() && c.isGenerated()) {
                    if (this.logger.isDebugEnabled()) {
                        this.logger.debug("adding generated key " + t.getTableName() + "." + c.getColumnName());
                    }

                    generatedKeys.put(t.getTableName(), c.getColumnName());
                }
            }
        }
    }
View Full Code Here

    public void testAddColumnWithPropertyName() throws SQLException {
        String statement = "SELECT * FROM BOOK WHERE BOOK.BOOK_ID = ?";

        // Create Table config programmatically
        ConfigHelper helper = new ConfigHelper();
        Table table = helper.addTable("BOOK", "Book");
        helper.addPrimaryKey("Book.BOOK_ID");
        helper.addColumn(table, "NAME", "bookName");
        DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());
        Command select = das.createCommand(statement);
        select.setParameter(1, Integer.valueOf(1));
View Full Code Here

     * Simple unit test for adding a Delete statement to a Table
     * @throws Exception
     */
    public void testAddDeleteStatement() throws Exception {
        ConfigHelper helper = new ConfigHelper();
        Table table = helper.addTable("widgets", "WIDGETS");
        helper.addDeleteStatement(table, "delete from widgets where id = ?", "ID");

        Config cfg = helper.getConfig();
        assertEquals(1, cfg.getTable().size());
        Table widgets = (Table) cfg.getTable().get(0);
        assertEquals("delete from widgets where id = ?", widgets.getDelete().getSql());
        assertEquals("WIDGETS", widgets.getTypeName());
        assertEquals("ID", widgets.getDelete().getParameters());

    }
View Full Code Here

     * Simple unit test for adding a Create statement to a Table
     * @throws Exception
     */
    public void testAddCreateStatement() throws Exception {
        ConfigHelper helper = new ConfigHelper();
        Table table = helper.addTable("widgets", "WIDGETS");
        helper.addCreateStatement(table, "insert into widgets values (?,?)", "ID NAME");

        Config cfg = helper.getConfig();
        assertEquals(1, cfg.getTable().size());
        Table widgets = (Table) cfg.getTable().get(0);
        assertEquals("insert into widgets values (?,?)", widgets.getCreate().getSql());
        assertEquals("WIDGETS", widgets.getTypeName());
        assertEquals("ID NAME", widgets.getCreate().getParameters());

    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.das.rdb.config.Table

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.