use of com.ctrip.platform.dal.dao.sqlbuilder.SelectSqlBuilder in project dal by ctripcorp.
the class DalTableDaoTestStub method testQueryObjectList.
@Test
public void testQueryObjectList() throws SQLException {
SelectSqlBuilder builder = new SelectSqlBuilder();
builder.equal("type", 1, Types.SMALLINT);
List<Short> models = dao.query(builder, new DalHints(), Short.class);
Assert.assertTrue(null != models);
Assert.assertEquals(3, models.size());
builder = new SelectSqlBuilder();
builder.equal("type", 1, Types.SMALLINT);
builder.orderBy("id", true);
models = dao.query(builder.atPage(1, 1), new DalHints(), Short.class);
Assert.assertTrue(null != models);
Assert.assertEquals(1, models.size());
builder = new SelectSqlBuilder();
builder.equal("type", 10, Types.SMALLINT);
builder.orderBy("id", true);
models = dao.query(builder.atPage(1, 10), new DalHints(), Short.class);
Assert.assertTrue(null != models);
Assert.assertEquals(0, models.size());
}
use of com.ctrip.platform.dal.dao.sqlbuilder.SelectSqlBuilder 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.sqlbuilder.SelectSqlBuilder 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.sqlbuilder.SelectSqlBuilder in project dal by ctripcorp.
the class DalTableDaoTestStub method testQueryList.
@Test
public void testQueryList() throws SQLException {
SelectSqlBuilder builder = new SelectSqlBuilder();
builder.equal("type", 1, Types.SMALLINT);
List<ClientTestModel> models = dao.query(builder, new DalHints());
Assert.assertTrue(null != models);
Assert.assertEquals(3, models.size());
builder = new SelectSqlBuilder();
builder.equal("type", 1, Types.SMALLINT);
builder.orderBy("id", true);
models = dao.query(builder.atPage(1, 1), new DalHints());
Assert.assertTrue(null != models);
Assert.assertEquals(1, models.size());
builder = new SelectSqlBuilder();
builder.equal("type", 10, Types.SMALLINT);
builder.orderBy("id", true);
models = dao.query(builder.atPage(1, 10), new DalHints());
Assert.assertTrue(null != models);
Assert.assertEquals(0, models.size());
}
use of com.ctrip.platform.dal.dao.sqlbuilder.SelectSqlBuilder in project dal by ctripcorp.
the class DalTableDaoTestStub method testQueryObject.
@Test
public void testQueryObject() throws SQLException {
SelectSqlBuilder builder = new SelectSqlBuilder();
builder.equal("type", 1, Types.SMALLINT);
builder.requireFirst();
Short models = dao.queryObject(builder, new DalHints(), Short.class);
Assert.assertNotNull(models);
builder = new SelectSqlBuilder();
builder.equal("type", 1, Types.SMALLINT);
builder.requireFirst();
models = dao.queryObject(builder.atPage(1, 1), new DalHints(), Short.class);
Assert.assertNotNull(models);
builder = new SelectSqlBuilder();
builder.equal("type", 10, Types.SMALLINT);
builder.requireFirst();
models = dao.queryObject(builder.atPage(1, 10), new DalHints(), Short.class);
Assert.assertNull(models);
}
Aggregations