use of com.ctrip.platform.dal.dao.DalRowCallback in project dal by ctripcorp.
the class DalQueryDaoTestStub method testQueryWithCallback.
/**
* Test the query function with callback
* @throws SQLException
*/
@Test
public void testQueryWithCallback() throws SQLException {
String sql = "SELECT * FROM " + TABLE_NAME + " WHERE id = 1";
final ClientTestModel model = new ClientTestModel();
DalRowCallback callback = new DalRowCallback() {
@Override
public void process(ResultSet rs) throws SQLException {
model.setId(rs.getInt(1));
model.setQuantity(rs.getInt(2));
model.setType(rs.getShort(3));
model.setAddress(rs.getString(4));
model.setLastChanged(rs.getTimestamp(5));
}
};
StatementParameters param = new StatementParameters();
DalHints hints = new DalHints();
client.query(sql, param, hints, callback);
Assert.assertEquals(1, model.getId().intValue());
}
Aggregations