Search in sources :

Example 1 with DAO

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;
}
Also used : DAO(org.eweb4j.orm.dao.DAO)

Example 2 with DAO

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;
}
Also used : DAO(org.eweb4j.orm.dao.DAO)

Example 3 with DAO

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());
}
Also used : DAO(org.eweb4j.orm.dao.DAO)

Example 4 with DAO

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!");
}
Also used : DAO(org.eweb4j.orm.dao.DAO) Pet(test.po.Pet)

Example 5 with DAO

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));
            }
        }
    }
}
Also used : Master(test.po.Master) DAO(org.eweb4j.orm.dao.DAO) Map(java.util.Map) Pet(test.po.Pet)

Aggregations

DAO (org.eweb4j.orm.dao.DAO)5 Pet (test.po.Pet)2 Map (java.util.Map)1 Master (test.po.Master)1