Package org.apache.ws.jaxme.sqls

Examples of org.apache.ws.jaxme.sqls.Table


    protected String getBulkInsertResult() {
        return "INSERT INTO MySchema.MyTable (MyTable.MyIndex, MyTable.MyName, MyTable.MyDate) (SELECT MyTable0.MyIndex, MyTable0.MyName, MyTable0.MyDate FROM MySchema.MyTable AS MyTable0)";
    }

    public void testBulkInsert() {
        Table table = getBasicTable();
        InsertStatement insertStatement = getSQLFactory().newInsertStatement();
        insertStatement.setTable(table);
        SelectStatement st = table.getSelectStatement();
        SQLGenerator generator = getSQLGenerator();
        generator.setLineTerminator("\n");
        insertStatement.setSubSelect(st);
        String got = generator.getQuery(insertStatement);
        String expect = getBulkInsertResult();
View Full Code Here


    }

    /** <p>Basic test for creating a <code>SELECT</code> statement.</p>
     */
    public void testBasicSelect() {
        Table table = getBasicTable();
        SelectStatement selectStatement = table.getSelectStatement();
        SQLGenerator generator = getSQLGenerator();
        generator.setLineTerminator("\n");
        String s = generator.getQuery(selectStatement);
        assertEquals("SELECT MyIndex, MyName, MyDate FROM MySchema.MyTable", s);
    }
View Full Code Here

    }
   
    /** <p>Basic test for creating an <code>UPDATE</code> statement.</p>
     */
    public void testBasicUpdate() {
        Table table = getPrimaryKeyTable();
        UpdateStatement updateStatement = table.getUpdateStatement();
        SQLGenerator generator = getSQLGenerator();
        generator.setLineTerminator("\n");
        String s = generator.getQuery(updateStatement);
        assertEquals("UPDATE MySchema.MyTable SET MyName=?, MyDate=? WHERE MyIndex=?", s);
    }
View Full Code Here

    }
   
    /** <p>Basic test for creating an <code>DELETE</code> statement.</p>
     */
    public void testBasicDelete() {
        Table table = getPrimaryKeyTable();
        DeleteStatement deleteStatement = table.getDeleteStatement();
        SQLGenerator generator = getSQLGenerator();
        generator.setLineTerminator("\n");
        String s = generator.getQuery(deleteStatement);
        assertEquals("DELETE FROM MySchema.MyTable WHERE MyIndex=?", s);
    }
View Full Code Here

    }
   
    /** <p>Test for a FOREIGN KEY definition.</p>
     */
    public void testCreateForeignKey() {
        Table table = getPrimaryKeyTable();
        Table otherTable = getForeignKeyTable(table);
        SQLGenerator generator = getSQLGenerator();
        Collection c = generator.getCreate(otherTable);
        assertEquals(1, c.size());
        String expect = getCreateForeignKeyResult();
        String got = (String) c.iterator().next();
View Full Code Here

    protected String getTestJoinResult() {
        return "SELECT OtherTable.MyIndex, RefIndex, Company FROM MySchema.OtherTable JOIN MySchema.MyTable ON RefIndex=MyTable.MyIndex WHERE OtherTable.MyIndex=?";
    }

    protected SelectStatement getJoinStatement() {
        Table table = getPrimaryKeyTable();
        Table otherTable = getForeignKeyTable(table);
        SelectStatement statement = otherTable.getSelectStatement();
        SelectTableReference tableReference = statement.getSelectTableReference();
        JoinReference joinReference = tableReference.join(table);
       
        TableReference refLocal = tableReference;
        TableReference refRef = tableReference.getRightJoinedTableReference();
       
        joinReference.getOn().addJoin((ForeignKey) otherTable.getForeignKeys().next(),
                refLocal, refRef);
        CombinedConstraint cc = statement.getWhere();
        BooleanConstraint bc = cc.createEQ();
        bc.addPart(tableReference.newColumnReference("MyIndex"));
        bc.addPlaceholder();
View Full Code Here

    }
   
    /** <p>Test for a LEFT OUTER JOIN statement.</p>
     */
    public void testLeftOuterJoin() {
        Table table = getPrimaryKeyTable();
        Table otherTable = getForeignKeyTable(table);
        SelectStatement statement = otherTable.getSelectStatement();
        SelectTableReference tableReference = statement.getSelectTableReference();
        JoinReference joinReference = tableReference.leftOuterJoin(table);
       
        TableReference refLocal = tableReference;
        TableReference refRef = tableReference.getRightJoinedTableReference();
       
        joinReference.getOn().addJoin((ForeignKey) otherTable.getForeignKeys().next(),
                refLocal, refRef);
        CombinedConstraint cc = statement.getWhere();
        BooleanConstraint bc = cc.createEQ();
        bc.addPart(tableReference.newColumnReference("MyIndex"));
        bc.addPlaceholder();
View Full Code Here

    }
   
    /** <p>Test for an EXISTS clause.</p>
     */
    public void testExists() {
        Table table = getPrimaryKeyTable();
        Table otherTable = getForeignKeyTable(table);
        SelectStatement statement = table.getSelectStatement();
        SelectTableReference tableReference = statement.getSelectTableReference();
        SelectStatement existsStatement = otherTable.getSelectStatement();
        SelectTableReference existsTableReference = existsStatement.getSelectTableReference();
        BooleanConstraint bc = existsStatement.getWhere().createEQ();
        bc.addPart(existsTableReference.newColumnReference("RefIndex"));
        bc.addPart(tableReference.newColumnReference("MyIndex"));
        statement.getWhere().createEXISTS(existsStatement);
View Full Code Here

    }

    /** <p>Test for a BETWEEN clause.</p>
     */
    public void testBetween() {
        Table table = getBasicTable();
        SelectStatement statement = table.getSelectStatement();
    BooleanConstraint between = statement.getWhere().createBETWEEN();
    between.addPart(statement.getTableReference().newColumnReference("MyIndex"));
    between.addPart(3);
    between.addPart(5);

View Full Code Here

    }

    /** <p>Creates a table with a composed primary key.</p>
     */
    protected Table getComposedKeyTable() {
        Table table = getPrimaryKeyTable();
        Column verNumColumn = table.newColumn("VerNum", Column.Type.INTEGER);
        assertTrue(!verNumColumn.isStringColumn());
        assertTrue(!verNumColumn.isBinaryColumn());
        Index index = table.getPrimaryKey();
        index.addColumn("VerNum");
        return table;
    }
View Full Code Here

TOP

Related Classes of org.apache.ws.jaxme.sqls.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.