use of org.eweb4j.orm.dao.DAO in project eweb4j-framework by laiweiwei.
the class ModelHelper method find.
public Query find() {
Class<?> clazz = this.model.getClass();
DAO dao = DAOFactory.getDAO(clazz, this.dsName);
dao.selectAll();
Query _query = new QueryImpl(dao);
return _query;
}
use of org.eweb4j.orm.dao.DAO in project eweb4j-framework by laiweiwei.
the class ModelHelper method find.
public Query find(String query, Object... params) {
Class<?> clazz = this.model.getClass();
DAO dao = DAOFactory.getDAO(clazz, this.dsName);
dao.selectAll().where().append(query).fillArgs(params);
Query _query = new QueryImpl(dao);
return _query;
}
use of org.eweb4j.orm.dao.DAO in project eweb4j-framework by laiweiwei.
the class TestDb method testNotMappingColumn.
public void testNotMappingColumn() throws Exception {
DAO dao = Db.ar(Pet.class).dao().update("fuckyou").set("heihei").where().field("id").equal(11);
String sql = dao.toSql();
List<Object> args = dao.getArgs();
System.out.println(sql + ", args->" + args);
Assert.assertEquals(" UPDATE t_pet SET fuckyou = ? WHERE id = ? ", sql);
Assert.assertEquals("[heihei, 11]", args.toString());
}
use of org.eweb4j.orm.dao.DAO in project eweb4j-framework by laiweiwei.
the class DAOTest method testDAO.
public void testDAO() {
DAO dao = DAOFactory.getDAO(Pet.class);
Pet pet = dao.clear().unfetch("user").selectAll().where().field("id").equal(5).queryOne();
//System.out.println(pet);
System.out.println("fck!");
}
use of org.eweb4j.orm.dao.DAO in project eweb4j-framework by laiweiwei.
the class DAOTest method testCol.
public void testCol() throws Exception {
Assert.assertEquals("pet.master_id", ORMConfigBeanUtil.getColumn(Master.class, "pets.master"));
// Collection<Object> ms = DAOFactory.getDAO(Master.class).enableExpress(false).select("*").join("pets").where().field("pet.name").equal("xiaohei").groupBy("pet.name").query();
// System.out.println(ms);
DAO dao = DAOFactory.getDAO(Pet.class).alias("p");
Pet pet = dao.join("master", "m").join("user", "u").unfetch("user").fetch("master").select(Pet.class).where().field("m.name").like("wei").and("p.name").likeLeft("xiao").and("u.account").equal("admin").groupBy("u.account").queryOne();
System.out.println("pet -> " + pet);
if (pet != null) {
System.out.println("master->" + pet.getMaster());
System.out.println("count->" + dao.count());
}
String sql = dao.toSql();
List<Map> maps = DAOFactory.getSelectDAO().selectBySQL(Map.class, sql);
if (maps != null) {
for (Map<String, Object> map : maps) {
for (String key : map.keySet()) {
System.out.println(key + "=>" + map.get(key));
}
}
}
}