Search in sources :

Example 16 with Master

use of test.po.Master in project eweb4j-framework by laiweiwei.

the class TestCascadeDAO method testManyManyUpdate.

/**
	 * 测试多对多更新
	 */
public static void testManyManyUpdate() {
    Master master = new Master().find().first();
    master.cascade().refresh(999, "pets");
}
Also used : Master(test.po.Master)

Example 17 with Master

use of test.po.Master in project eweb4j-framework by laiweiwei.

the class TestCascadeDAO method testManyManySelect.

public static void testManyManySelect() {
    // List<Master> masterList = DAOFactory.getSelectDAO().selectAll(
    // Master.class);
    // if (masterList != null) {
    // for (Master m : masterList) {
    // System.out.println(m + "|" + m.getPets());
    // DAOFactory.getCascadeDAO().select(m, "pets");
    // System.out.println(m.getPets());
    // break;
    // }
    // }
    // List<Pet> petList;
    // try {
    // petList = DAOFactory.getSelectDAO().selectAll(Pet.class);
    // if (petList != null) {
    // for (Pet p : petList) {
    // System.out.println(p + "|" + p.getMasters());
    // DAOFactory.getCascadeDAO().select(p);
    // System.out.println(p.getMasters());
    // break;
    // }
    // }
    // } catch (DAOException e) {
    // // TODO Auto-generated catch block
    // e.printStackTrace();
    // }
    List<Master> 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 + "|" + m.getPets());
            break;
        }
    }
}
Also used : Master(test.po.Master)

Example 18 with Master

use of test.po.Master in project eweb4j-framework by laiweiwei.

the class TestCascadeDAO method testManyDelete.

public static void testManyDelete() {
    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().delete(m, "pets");
            }
        }
    } catch (DAOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : Master(test.po.Master) DAOException(org.eweb4j.orm.dao.DAOException)

Aggregations

Master (test.po.Master)18 Pet (test.po.Pet)8 Test (org.junit.Test)6 DAOException (org.eweb4j.orm.dao.DAOException)4 Sql (org.eweb4j.orm.sql.Sql)4 Map (java.util.Map)1 DAO (org.eweb4j.orm.dao.DAO)1 ReflectUtil (org.eweb4j.util.ReflectUtil)1 BeforeClass (org.junit.BeforeClass)1