Package org.apache.metamodel

Examples of org.apache.metamodel.MockUpdateableDataContext.query()


        final Table table = dc.getDefaultSchema().getTables()[0];
        Map<Column, TypeConverter<?, ?>> converters = Converters.autoDetectConverters(dc, table, 1000);
        assertEquals(1, converters.size());
        dc = Converters.addTypeConverters(dc, converters);

        final Query q = dc.query().from(table).select("foo").toQuery();
        assertEquals("SELECT table.foo FROM schema.table", q.toSql());
        DataSet ds = dc.executeQuery(q);
        assertTrue(ds.next());
        assertEquals(1, ds.getRow().getValue(0));
        assertTrue(ds.next());
View Full Code Here


    dc = Converters.addTypeConverter(dc, fooColumn,
        new StringToIntegerConverter());

    Table table = dc.getDefaultSchema().getTableByName("table");
    Query query = dc.query().from(table).select(table.getColumns())
        .toQuery();
    assertEquals("SELECT table.foo, table.bar FROM schema.table",
        query.toSql());

    DataSet ds = dc.executeQuery(query);
View Full Code Here

public class AbstractRowDeletionCallbackTest extends TestCase {

    public void testDelete() throws Exception {
        final MockUpdateableDataContext dc = new MockUpdateableDataContext();
        final Table table = dc.getDefaultSchema().getTables()[0];
        DataSet ds = dc.query().from(table).selectCount().execute();
        assertTrue(ds.next());
        assertEquals("3", ds.getRow().getValue(0).toString());
        assertFalse(ds.next());
        ds.close();
View Full Code Here

                callback.update(table).value("bar", "baz").execute();
                callback.update(table).value("foo", "4").where("foo").eq("3").execute();
            }
        });

        ds = dc.query().from(table).select(table.getColumns()).execute();
        assertTrue(ds.next());
        assertEquals("Row[values=[1, baz]]", ds.getRow().toString());
        assertTrue(ds.next());
        assertEquals("Row[values=[2, baz]]", ds.getRow().toString());
        assertTrue(ds.next());
View Full Code Here

                assertEquals("DELETE FROM schema.table WHERE table.bar = 'baz'", callback.deleteFrom(table).where("bar")
                        .eq("baz").toSql());
            }
        });

        ds = dc.query().from(table).selectCount().execute();
        assertTrue(ds.next());
        assertEquals("0", ds.getRow().getValue(0).toString());
        assertFalse(ds.next());
        ds.close();
    }
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.