use of org.nutz.dao.Condition in project nutz by nutzam.
the class CndTest method test_segment.
@Test
public void test_segment() {
Map<String, Object> map = new HashMap<String, Object>();
map.put("name", "比尔盖茨");
map.put("age", 50);
Condition c1 = Cnd.wrap("name='${name}' AND age>${age}", map);
assertEquals("name='比尔盖茨' AND age>50", c1.toSql(en));
Worker worker = new Worker();
worker.name = "老板";
worker.age = 30;
Condition c2 = Cnd.wrap("name like'${name}%' AND age>${age}", worker);
assertEquals("name like'老板%' AND age>30", c2.toSql(en));
}
use of org.nutz.dao.Condition in project nutz by nutzam.
the class CndTest method test_gt_like.
@Test
public void test_gt_like() {
Condition c = Cnd.where("id", ">", 45).and("name", "LIKE", "%ry%");
String exp = "WHERE wid>45 AND wname LIKE '%ry%'";
assertEquals(exp, c.toSql(en).trim());
}
use of org.nutz.dao.Condition in project nutz by nutzam.
the class CndTest method test_bracket.
@Test
public void test_bracket() {
Condition c = Cnd.where(Cnd.exps("id", ">", 45)).and("name", "LIKE", "%ry%");
String exp = "WHERE (wid>45) AND wname LIKE '%ry%'";
assertEquals(exp, c.toSql(en).trim());
}
use of org.nutz.dao.Condition in project nutz by nutzam.
the class CndTest method test_equel.
@Test
public void test_equel() {
Condition c = Cnd.where("ff", "=", true);
String exp = "WHERE ff=true";
assertEquals(exp, c.toSql(en).trim());
}
use of org.nutz.dao.Condition in project nutz by nutzam.
the class SimpleDaoTest method test_count_with_entity.
@Test
public void test_count_with_entity() {
insertRecords(8);
int re = dao.count(Pet.class, new Condition() {
/**
*
*/
private static final long serialVersionUID = 6425274813857908874L;
public String toSql(Entity<?> entity) {
return entity.getField("nickName").getColumnName() + " IN ('alias_5','alias_6')";
}
});
assertEquals(2, re);
}