Search in sources :

Example 1 with PojoMaker

use of org.nutz.dao.sql.PojoMaker in project nutz by nutzam.

the class NutPojoMakerTest method makeQueryByJoin.

@Test
public void makeQueryByJoin() {
    dao.create(Pet.class, true);
    dao.create(Master.class, true);
    Master master = new Master();
    master.setName("zozoh");
    Pet petA = new Pet();
    petA.setName("wendal");
    petA.setAge(31);
    Pet petB = new Pet();
    petB.setName("pangwu");
    petB.setAge(30);
    master.setPets(Arrays.asList(petA, petB));
    dao.insertWith(master, null);
    PojoMaker pojoMaker = new NutPojoMaker(dao.getJdbcExpert());
    Entity<?> en = en(Master.class);
    Pojo pojo = pojoMaker.makeQueryByJoin(en, "pets");
    assertEquals(true, Lang.isNotEmpty(pojo));
}
Also used : Master(org.nutz.dao.test.meta.Master) Pojo(org.nutz.dao.sql.Pojo) Pet(org.nutz.dao.test.meta.Pet) PojoMaker(org.nutz.dao.sql.PojoMaker) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 Pojo (org.nutz.dao.sql.Pojo)1 PojoMaker (org.nutz.dao.sql.PojoMaker)1 Master (org.nutz.dao.test.meta.Master)1 Pet (org.nutz.dao.test.meta.Pet)1