use of com.ctrip.platform.dal.dao.DalHints in project dal by ctripcorp.
the class PartialQueryTableDaoUnitTest method testDetectFieldNotExist.
@Test
public void testDetectFieldNotExist() throws Exception {
DalTableDao<PersonWithoutName> client = new DalTableDao<>(new DalDefaultJpaParser<>(PersonWithoutName.class));
List<Integer> peopleIds = new ArrayList<>();
peopleIds.add(1);
peopleIds.add(2);
peopleIds.add(3);
List<Integer> cityIds = new ArrayList<>();
cityIds.add(1);
cityIds.add(2);
cityIds.add(3);
SelectSqlBuilder builder = new SelectSqlBuilder();
builder.select("DataChange_LastTime", "CityID", "Name", "ProvinceID", "PeopleID", "CountryID");
builder.in("PeopleID", peopleIds, Types.INTEGER, false);
builder.and();
builder.in("CityID", cityIds, Types.INTEGER, false);
try {
client.query(builder, new DalHints().inAllShards().inTableShard(1));
Assert.fail();
} catch (DalException e) {
e.printStackTrace();
assertEquals(ErrorCode.FieldNotExists.getCode(), e.getErrorCode());
}
}
use of com.ctrip.platform.dal.dao.DalHints in project dal by ctripcorp.
the class DalColumnMapRowMapperTest method tearDownAfterClass.
@AfterClass
public static void tearDownAfterClass() throws Exception {
DalHints hints = new DalHints();
StatementParameters parameters = new StatementParameters();
String[] sqls = new String[] { DROP_TABLE_SQL };
for (int i = 0; i < sqls.length; i++) {
client.update(sqls[i], parameters, hints);
}
}
use of com.ctrip.platform.dal.dao.DalHints in project dal by ctripcorp.
the class DalColumnMapRowMapperTest method setUp.
@Before
public void setUp() throws Exception {
DalHints hints = new DalHints();
String[] insertSqls = new String[] { "SET IDENTITY_INSERT " + TABLE_NAME + " ON", "INSERT INTO " + TABLE_NAME + "(Id, quantity,type,address)" + " VALUES(1, 10, 1, 'SH INFO')", "INSERT INTO " + TABLE_NAME + "(Id, quantity,type,address)" + " VALUES(2, 11, 1, 'BJ INFO')", "INSERT INTO " + TABLE_NAME + "(Id, quantity,type,address)" + " VALUES(3, 12, 2, 'SZ INFO')", "SET IDENTITY_INSERT " + TABLE_NAME + " OFF" };
client.batchUpdate(insertSqls, hints);
}
use of com.ctrip.platform.dal.dao.DalHints in project dal by ctripcorp.
the class DalColumnMapRowMapperTest method testDalColumnMapRowMapperEmpty.
@Test
public void testDalColumnMapRowMapperEmpty() {
try {
StatementParameters parameters = new StatementParameters();
DalClient client = DalClientFactory.getClient(DATABASE_NAME);
List<Map<String, Object>> result1 = client.query(sqlNoResult, parameters, new DalHints(), new DalRowMapperExtractor<Map<String, Object>>(new DalColumnMapRowMapper()));
assertEquals(0, result1.size());
DalQueryDao dao = new DalQueryDao(DATABASE_NAME);
List<Map<String, Object>> result = dao.query(sqlNoResult, parameters, hints, new DalColumnMapRowMapper());
assertEquals(0, result.size());
} catch (Exception e) {
fail();
}
}
use of com.ctrip.platform.dal.dao.DalHints in project dal by ctripcorp.
the class MySqlHelperTest method tearDownAfterClass.
@AfterClass
public static void tearDownAfterClass() throws Exception {
DalHints hints = new DalHints();
String[] sqls = new String[] { DROP_TABLE_SQL_MYSQL_TPL };
clientMySql.batchUpdate(sqls, hints);
}
Aggregations