use of test.po.Master in project eweb4j-framework by laiweiwei.
the class TestDb method testOrmUtil.
public void testOrmUtil() throws Exception {
String[] fields = new ReflectUtil(Master.class).getFieldsName();
System.out.println(Arrays.asList(fields));
Master m = DAOFactory.getDAO(Master.class).fetch("pets").selectAll().queryOne();
System.out.println(m);
}
use of test.po.Master 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));
}
}
}
}
use of test.po.Master in project eweb4j-framework by laiweiwei.
the class TestSelectSql method prepare.
@BeforeClass
public static void prepare() throws Exception {
String err = EWeb4JConfig.start("start.eweb.xml");
if (err != null) {
System.out.println(">>>EWeb4J Start Error --> " + err);
System.exit(-1);
}
pet = new Pet();
master = new Master();
master.setId(5L);
pet.setMaster(master);
pet.setName("xiaobai");
select = SqlFactory.getSelectSql(pet, "mysql");
fieldAdd = "+0";
}
use of test.po.Master in project eweb4j-framework by laiweiwei.
the class TestUpdateSql method testUpdateByField.
/**
* 修改给定字段
*
* @param t
* 给定的对象
* @param fields
* 给定的字段
* @return 返回布尔
*/
@Test
public <T> void testUpdateByField() {
pet.setName("xiaohuang");
pet.setAge(3);
pet.setPetId(12L);
Master master = new Master();
master.setId(5L);
pet.setMaster(master);
String[] fields = { "name", "age", "master" };
Sql sql = update.update(fields)[0];
Assert.assertEquals("UPDATE t_pet SET name = ? , age = ? , master_id = ? WHERE id = ? ;", sql.sql);
Assert.assertEquals("xiaohuang", sql.args.get(0));
Assert.assertEquals(3, sql.args.get(1));
Assert.assertEquals(5l, sql.args.get(2));
Assert.assertEquals(12l, sql.args.get(3));
}
use of test.po.Master in project eweb4j-framework by laiweiwei.
the class CascadeTest method testOneRel.
@Test
public void testOneRel() throws Exception {
Master master = new Master();
master.setId(1L);
master.getPets().add(new Pet());
master.getPets().add(new Pet());
master.getPets().add(new Pet());
//DAOFactory.getCascadeDAO().insert(master, "pets");
Assert.assertEquals(true, true);
}
Aggregations