Package org.apache.ws.jaxme.sqls

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


        Table table = getBasicTable();
        SelectStatement selectStatement = table.getSelectStatement();
        VirtualColumn col = new VirtualColumn("virtCol", Column.Type.VARCHAR);
        selectStatement.addResultColumn(col);
        col.setValue("null");
        SQLGenerator gen = getSQLGenerator();
        String query = gen.getQuery(selectStatement);
        assertEquals("SELECT MyIndex, MyName, MyDate, null AS virtCol FROM MySchema.MyTable", query);
    }
View Full Code Here


        CombinedConstraint or = and.createOrConstraint();
        or.setNOT(true);
        bc = or.createEQ();
        bc.addPart(ref.newColumnReference("MyIndex"));
        bc.addPart(1);
        SQLGenerator gen = getSQLGenerator();
        String query = gen.getQuery(selectStatement);
        assertEquals("SELECT MyIndex, MyName, MyDate FROM MySchema.MyTable WHERE (MyName LIKE '%a%' AND NOT (MyIndex=1))", query);

        bc = or.createEQ();
        bc.addPart(ref.newColumnReference("MyIndex"));
        bc.addPart(2);
        query = gen.getQuery(selectStatement);
        assertEquals("SELECT MyIndex, MyName, MyDate FROM MySchema.MyTable WHERE (MyName LIKE '%a%' AND (NOT (MyIndex=1 OR MyIndex=2)))", query);
    }
View Full Code Here

    Expression e1 = bc.createSUM();
    e1.addPart(ref.newColumnReference("MyIndex"));
    e1.addPart(3);
    Expression e2 = bc.createSUM();
    e2.addPart(5);
        SQLGenerator gen = getSQLGenerator();
        String got = gen.getQuery(st);
    String expect = "SELECT MyIndex, MyName, MyDate FROM MySchema.MyTable WHERE (MyIndex+3)>5";
    assertEquals(expect, got);
  }
View Full Code Here

        bc = connectByPrior.createEQ();
        OraColumnReference oraRef = (OraColumnReference) ref.newColumnReference("MyIndex");
        oraRef.setPrior(true);
        bc.addPart(oraRef);
        bc.addPart(ref.newColumnReference("MyName"));
        SQLGenerator gen = getSQLGenerator();
        String query = gen.getQuery(selectStatement);
        assertEquals("SELECT MyIndex, MyName, MyDate FROM MySchema.MyTable START WITH MyIndex=1 CONNECT BY PRIOR MyIndex=MyName", query);
    }
View Full Code Here

  /** <p>Basic test for creating a <code>CREATE TABLE</code>
   * statement.</p>
   */
  public void testBasicCreate() {
    Table table = getBasicTable();
    SQLGenerator generator = getSQLGenerator();
    generator.setLineTerminator("\n");
    Collection statements = generator.getCreate(table.getSchema(), true);
    Iterator iter = statements.iterator();
    assertTrue(iter.hasNext());
    assertEquals("CREATE SCHEMA MySchema", iter.next());
    assertTrue(iter.hasNext());
    assertEquals("CREATE TABLE MySchema.MyTable (\n" +
View Full Code Here

  /** <p>Basic test for creating an <code>INSERT</code> statement.</p>
   */
  public void testBasicInsert() {
    Table table = getBasicTable();
    InsertStatement insertStatement = table.getInsertStatement();
    SQLGenerator generator = getSQLGenerator();
    generator.setLineTerminator("\n");
    String s = generator.getQuery(insertStatement);
    assertEquals("INSERT INTO MySchema.MyTable (MyIndex, MyName, MyDate) VALUES (?, ?, ?)", s);
  }
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();
     assertEquals(expect, got);
  }
View Full Code Here

TOP

Related Classes of org.apache.ws.jaxme.sqls.SQLGenerator

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.