Search in sources :

Example 66 with Pojo

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

the class Pojos method pojo.

public static Pojo pojo(JdbcExpert expert, Entity<?> en, SqlType type) {
    Pojo pojo = expert.createPojo(type);
    pojo.getContext().setFieldMatcher(FieldFilter.get(en.getType()));
    return pojo;
}
Also used : NutPojo(org.nutz.dao.impl.jdbc.NutPojo) Pojo(org.nutz.dao.sql.Pojo)

Example 67 with Pojo

use of org.nutz.dao.sql.Pojo 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

Pojo (org.nutz.dao.sql.Pojo)67 SqlFieldMacro (org.nutz.dao.impl.entity.macro.SqlFieldMacro)6 LinkField (org.nutz.dao.entity.LinkField)5 LinkVisitor (org.nutz.dao.entity.LinkVisitor)5 ExitLoop (org.nutz.lang.ExitLoop)5 LoopException (org.nutz.lang.LoopException)5 DaoException (org.nutz.dao.DaoException)4 ManyManyLinkField (org.nutz.dao.impl.entity.field.ManyManyLinkField)4 Criteria (org.nutz.dao.sql.Criteria)4 PItem (org.nutz.dao.sql.PItem)4 ArrayList (java.util.ArrayList)3 DoClearLinkVisitor (org.nutz.dao.impl.link.DoClearLinkVisitor)3 DoClearRelationByHostFieldLinkVisitor (org.nutz.dao.impl.link.DoClearRelationByHostFieldLinkVisitor)3 DoClearRelationByLinkedFieldLinkVisitor (org.nutz.dao.impl.link.DoClearRelationByLinkedFieldLinkVisitor)3 DoDeleteLinkVisitor (org.nutz.dao.impl.link.DoDeleteLinkVisitor)3 DoInsertLinkVisitor (org.nutz.dao.impl.link.DoInsertLinkVisitor)3 DoInsertRelationLinkVisitor (org.nutz.dao.impl.link.DoInsertRelationLinkVisitor)3 DoUpdateLinkVisitor (org.nutz.dao.impl.link.DoUpdateLinkVisitor)3 DoUpdateRelationLinkVisitor (org.nutz.dao.impl.link.DoUpdateRelationLinkVisitor)3 ConditionPItem (org.nutz.dao.impl.sql.pojo.ConditionPItem)3