use of org.eweb4j.orm.sql.Sql in project eweb4j-framework by laiweiwei.
the class TestDeleteSql method testDeleteByOneRelField.
/**
* 测试一(多)对一关系的删除sql语句生成
*
* @throws Exception
*/
@Test
public void testDeleteByOneRelField() throws Exception {
Master master = new Master();
master.setId(5L);
pet.setMaster(master);
String[] fields = { "master" };
Sql sql = delete.delete(fields)[0];
Assert.assertEquals("DELETE FROM t_pet WHERE master_id = ? ;", sql.sql);
Assert.assertEquals(5l, sql.args.get(0));
}
use of org.eweb4j.orm.sql.Sql in project eweb4j-framework by laiweiwei.
the class TestDeleteSql method testDeleteByFieldAndValue.
/**
* 删除记录,按给定字段、给定值
*
* @param clazz
* @param fields
* @param values
* @return
*/
@Test
public void testDeleteByFieldAndValue() {
Sql sql = delete.delete(new String[] { "age" }, new String[] { "50" })[0];
Assert.assertEquals("DELETE FROM t_pet WHERE age = ? ;", sql.sql);
Assert.assertEquals("50", sql.args.get(0));
}
use of org.eweb4j.orm.sql.Sql in project eweb4j-framework by laiweiwei.
the class TestDeleteSql method testDeleteWhereByArgs.
/**
* 给定条件删除记录,支持?占位符
*
* @param clazz
* @param condition
* @param args
* @return
*/
public void testDeleteWhereByArgs() {
Sql sql = delete.deleteWhere("name = ?");
Assert.assertEquals("DELETE FROM t_pet WHERE name = ? ;", sql.sql);
}
use of org.eweb4j.orm.sql.Sql in project eweb4j-framework by laiweiwei.
the class TestDeleteSql method testDeleteWhere.
/**
* 给定条件删除记录
*
* @param clazz
* @param condition
* @return
*/
public void testDeleteWhere() {
pet.setName("weiwei");
Sql sql = delete.deleteWhere("name = ?");
Assert.assertEquals("DELETE FROM t_pet WHERE name = ? ;", sql.sql);
Assert.assertEquals("weiwei", sql.args.get(0));
}
use of org.eweb4j.orm.sql.Sql in project eweb4j-framework by laiweiwei.
the class TestDeleteSql method testMap.
@Test
public void testMap() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
map.put("table", "t_pet");
map.put("idColumn", "id");
map.put("idValue", 7);
Pet pet = new Pet();
DeleteSqlCreator<?> delete = SqlFactory.getDeleteSql(map, pet);
Sql sql = delete.delete()[0];
Assert.assertEquals("DELETE FROM t_pet WHERE id = ? ;", sql.sql);
Assert.assertEquals(7, sql.args.get(0));
}
Aggregations