use of org.apache.cayenne.QueryResult in project cayenne by apache.
the class SQLExecIT method test_ExecuteSelect.
@Test
public void test_ExecuteSelect() throws Exception {
int inserted = SQLExec.query("INSERT INTO ARTIST (ARTIST_ID, ARTIST_NAME) VALUES (1, 'a')").update(context);
assertEquals(1, inserted);
QueryResult result = SQLExec.query("SELECT * FROM ARTIST").execute(context);
assertEquals(2, result.size());
assertTrue(result.isList());
assertEquals(1, result.firstList().size());
DataRow row = (DataRow) result.firstList().get(0);
if (unitDbAdapter.isLowerCaseNames()) {
assertTrue(row.containsKey("artist_id"));
assertEquals(1L, ((Number) row.get("artist_id")).longValue());
assertEquals("a", row.get("artist_name"));
} else {
assertTrue(row.containsKey("ARTIST_ID"));
assertEquals(1L, ((Number) row.get("ARTIST_ID")).longValue());
assertEquals("a", row.get("ARTIST_NAME"));
}
}
Aggregations