Package org.apache.metamodel.query

Examples of org.apache.metamodel.query.Query.toSql()


        FromItem fromItem1 = q.from(table, "t1").getFromClause().getItem(0);
        FromItem fromItem2 = q.from(table, "t2").getFromClause().getItem(1);
        q.select(table.getColumnByName("foo"), fromItem1);
        q.select(table.getColumnByName("foo"), fromItem2);
        q.where(q.getSelectClause().getItem(0), OperatorType.EQUALS_TO, "2");
        assertEquals("SELECT t1.foo, t2.foo FROM sch.tab t1, sch.tab t2 WHERE t1.foo = '2'", q.toSql());

        DataSet ds = dc.executeQuery(q);
        SelectItem[] selectItems = ds.getSelectItems();
        assertEquals(2, selectItems.length);
        assertEquals("t1.foo", selectItems[0].toSql());
View Full Code Here


        File file = new File("src/test/resources/csv_people.csv");
        QueryPostprocessDataContext dc = new CsvDataContext(file, new CsvConfiguration(1, true, true));
        Table table = dc.getDefaultSchema().getTableByName("csv_people.csv");

        Query q = dc.query().from(table).as("t").select("name").and("age").where("age").in("18", "20").toQuery();
        assertEquals("SELECT t.name, t.age FROM resources.csv_people.csv t WHERE t.age IN ('18' , '20')", q.toSql());

        DataSet ds = dc.executeQuery(q);
        assertTrue(ds.next());
        assertEquals("Row[values=[mike, 18]]", ds.getRow().toString());
        assertTrue(ds.next());
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.