use of test.po.Master in project eweb4j-framework by laiweiwei.
the class TestCascadeDAO method main.
public static void main(String[] args) throws Exception {
String err = EWeb4JConfig.start("start.eweb.xml");
if (err != null)
throw new Exception(err);
// TestCascadeDAO.testOneSelect();
// TestCascadeDAO.testOneUpdate();
// TestCascadeDAO.testManyInsert();
// TestCascadeDAO.testManySelect();
// TestCascadeDAO.testManyDelete();
// TestCascadeDAO.testManyManyInsert();
// TestCascadeDAO.testManyManySelect();
// TestCascadeDAO.testManyManyDelete();
// TestCascadeDAO.testManyManyUpdate();
Master master = new Master().findById(1);
System.out.println("=============== " + master);
master.cascade().fetch("pets");
System.out.println("===after==" + master);
// master.cascade().refresh(2, "pets");
// master = new Master();
// master.setId(1);
// Pet pet = new Pet();
// pet.setName("edit_fuck_name");
// pet.setNumber("testnumber");
// master.getPets().add(pet);
// master.cascade().persist("pets");
Pet pet = new Pet().find().first();
pet.setName("change_" + pet.getName());
pet.save();
System.out.println(pet);
//master.cascade().remove("pets");
}
use of test.po.Master in project eweb4j-framework by laiweiwei.
the class TestCascadeDAO method testManyManyInsert.
public static void testManyManyInsert() {
// Pet pet = new Pet();
// pet.setName("test");
// pet.setType("dog");
// pet.setAge(3);
//
// Master master = new Master();
// master.setName("_test");
// master.setGender("man");
//
// pet.getMasters().add(master);
//
// master = new Master();
// master.setName("_test1");
// master.setGender("man1");
//
// pet.getMasters().add(master);
//
// master = new Master();
// master.setName("_test2");
// master.setGender("man2");
//
// pet.getMasters().add(master);
//
// master = new Master();
// master.setName("_test3");
// master.setGender("man3");
//
// pet.getMasters().add(master);
// boolean flag = DAOFactory.getCascadeDAO().insert(pet);
// System.out.println(flag);
Master master = new Master();
// master.setId(36);
master.setName("日本人");
master.setGender("boy");
Pet pet = new Pet();
pet.setName("小日1");
pet.setType("dog");
pet.setPetId(6490L);
master.getPets().add(pet);
pet = new Pet();
pet.setName("小日2");
pet.setType("cat");
master.getPets().add(pet);
DAOFactory.getCascadeDAO().insert(master);
}
use of test.po.Master in project eweb4j-framework by laiweiwei.
the class TestCascadeDAO method testManyInsert.
public static void testManyInsert() {
Master master = new Master();
master.setName("小日主人1");
master.setGender("boy");
long id = (Integer) DAOFactory.getInsertDAO().insert(master);
master.setId(id);
Pet pet = new Pet();
pet.setName("小日1");
pet.setType("dog");
master.getPets().add(pet);
pet = new Pet();
pet.setName("小日2");
pet.setType("cat");
master.getPets().add(pet);
DAOFactory.getCascadeDAO().insert(master);
}
use of test.po.Master in project eweb4j-framework by laiweiwei.
the class TestCascadeDAO method testManySelect.
public static void testManySelect() {
List<Master> masterList;
try {
masterList = DAOFactory.getSelectDAO().selectAll(Master.class);
if (masterList != null) {
for (Master m : masterList) {
System.out.println(m + "|" + m.getPets());
DAOFactory.getCascadeDAO().select(m);
System.out.println(m.getPets());
// break;
}
}
} catch (DAOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of test.po.Master in project eweb4j-framework by laiweiwei.
the class TestCascadeDAO method testManyManyDelete.
public static void testManyManyDelete() {
List<Master> masterList;
try {
masterList = DAOFactory.getSelectDAO().selectAll(Master.class);
if (masterList != null) {
for (Master m : masterList) {
System.out.println(m + "|" + m.getPets());
Pet p = new Pet();
p.setPetId(5L);
m.getPets().add(p);
DAOFactory.getCascadeDAO().delete(m, "pets");
break;
}
}
} catch (DAOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Aggregations