use of test.po.Pet 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 test.po.Pet 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.Pet in project eweb4j-framework by laiweiwei.
the class TestPersistence method save.
public void save() {
EntityManagerFactory emf = Persistence.createEntityManagerFactory("JPAPU");
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
Pet pet = new Pet();
pet.setNumber("weejkl");
pet.setAge(2);
pet.setName("非常小");
pet.setType("dog");
em.persist(pet);
em.getTransaction().commit();
emf.close();
}
use of test.po.Pet in project eweb4j-framework by laiweiwei.
the class TestService method testTrans.
// 测试事务
public String testTrans(Pet _pet) {
String error = null;
// 事务模板
Transaction.execute(new Trans() {
@Override
public void run(Object... args) throws Exception {
// some eweb4j dao
}
}, 1, 2);
List<Pet> pets;
pets = DAOFactory.getSelectDAO().selectAll(Pet.class);
if (pets != null) {
}
return error;
}
use of test.po.Pet in project eweb4j-framework by laiweiwei.
the class TestDeleteSql 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();
pet.setAge(30);
delete = SqlFactory.getDeleteSql(pet);
}
Aggregations