Package org.apache.metamodel.query

Examples of org.apache.metamodel.query.FilterClause


        return toSql();
    }

    @Override
    public String toSql() {
        return "DELETE FROM " + _table.getQualifiedLabel() + new FilterClause(null, " WHERE ").addItems(_whereItems);
    }
View Full Code Here


    public void testSimpleSelectFromWhere() throws Exception {
        Query q = MetaModelHelper.parseQuery(dc, "SELECT foo FROM sch.tbl WHERE bar = 'baz' AND baz > 5");
        assertEquals("SELECT tbl.foo FROM sch.tbl WHERE tbl.bar = 'baz' AND tbl.baz > 5", q.toSql());

        FilterClause whereClause = q.getWhereClause();
        assertEquals(2, whereClause.getItemCount());
        assertNull("WHERE item was an expression based item, which indicates it was not parsed", whereClause.getItem(0)
                .getExpression());
        assertEquals(2, whereClause.getItemCount());
        assertNull("WHERE item was an expression based item, which indicates it was not parsed", whereClause.getItem(1)
                .getExpression());

        assertEquals("baz", whereClause.getItem(0).getOperand());
        assertEquals(Integer.class, whereClause.getItem(1).getOperand().getClass());
    }
View Full Code Here

    public void testCoumpoundWhereClause() throws Exception {
        Query q = MetaModelHelper
                .parseQuery(dc, "SELECT foo FROM sch.tbl WHERE (bar = 'baz' OR (baz > 5 AND baz < 7))");
        assertEquals("SELECT tbl.foo FROM sch.tbl WHERE (tbl.bar = 'baz' OR (tbl.baz > 5 AND tbl.baz < 7))", q.toSql());

        FilterClause wc = q.getWhereClause();
        assertEquals(1, wc.getItemCount());
        FilterItem item = wc.getItem(0);
        assertTrue(item.isCompoundFilter());

        FilterItem[] childItems = item.getChildItems();
        assertEquals(2, childItems.length);
View Full Code Here

            sb.append('=');
            sb.append(values[i] == null ? "NULL" : values[i].toString());
        }

        List<FilterItem> whereItems = getWhereItems();
        String whereClause = new FilterClause(null, " WHERE ").addItems(whereItems).toSql();
        sb.append(whereClause);
        return sb.toString();
    }
View Full Code Here

TOP

Related Classes of org.apache.metamodel.query.FilterClause

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.