use of com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.
the class DalTableDaoTestStub method testQueryFirstWithSelectSqlBuilder.
@Test
public void testQueryFirstWithSelectSqlBuilder() throws SQLException {
String whereClause = "type=?";
StatementParameters parameters = new StatementParameters();
parameters.set(1, Types.SMALLINT, 1);
SelectSqlBuilder builder = new SelectSqlBuilder().where(whereClause).with(parameters);
ClientTestModel model = dao.queryFirst(builder, new DalHints());
Assert.assertTrue(null != model);
Assert.assertEquals(1, model.getId().intValue());
}
use of com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.
the class DalTableDaoTestStub method testDeleteMultiple.
/**
* Test delete multiple entities
*
* @throws SQLException
*/
@Test
public void testDeleteMultiple() throws SQLException {
List<ClientTestModel> modelList = new ArrayList<>();
for (int i = 0; i < 3; i++) {
ClientTestModel model = new ClientTestModel();
model.setId(i + 1);
modelList.add(model);
}
int[] res = dao.delete(new DalHints(), modelList);
assertEquals(new int[] { 1, 1, 1 }, res, 4 - 3);
}
use of com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.
the class DalTableDaoTestStub method testQueryObjectAllColumns.
@Test
public void testQueryObjectAllColumns() throws SQLException {
SelectSqlBuilder builder = new SelectSqlBuilder().selectAllColumns();
builder.equal("type", 1, Types.SMALLINT);
builder.requireFirst();
ClientTestModel models = dao.queryObject(builder, new DalHints());
Assert.assertNotNull(models);
builder = new SelectSqlBuilder().selectAllColumns();
builder.equal("type", 1, Types.SMALLINT);
builder.requireFirst();
models = dao.queryObject(builder.atPage(1, 1), new DalHints());
Assert.assertNotNull(models);
builder = new SelectSqlBuilder().selectAllColumns();
builder.equal("type", 10, Types.SMALLINT);
builder.requireFirst();
models = dao.queryObject(builder.atPage(1, 10), new DalHints());
Assert.assertNull(models);
}
use of com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.
the class DalTableDaoTestStub method testQueryFirstWithWhereClause.
/**
* Test Query the first row with where clause
*
* @throws SQLException
*/
@Test
public void testQueryFirstWithWhereClause() throws SQLException {
String whereClause = "type=?";
StatementParameters parameters = new StatementParameters();
parameters.set(1, Types.SMALLINT, 1);
ClientTestModel model = dao.queryFirst(whereClause, parameters, new DalHints());
Assert.assertTrue(null != model);
Assert.assertEquals(1, model.getId().intValue());
}
use of com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.
the class DalTableDaoTestStub method testQueryByPkWithEntity.
/**
* Query by Entity with Primary key
*
* @throws SQLException
*/
@Test
public void testQueryByPkWithEntity() throws SQLException {
ClientTestModel pk = new ClientTestModel();
pk.setId(1);
ClientTestModel model = dao.queryByPk(pk, new DalHints());
Assert.assertTrue(null != model);
Assert.assertEquals(10, model.getQuantity().intValue());
}
Aggregations