Search in sources :

Example 46 with Pojo

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

the class NutDao method countByJoin.

public <T> int countByJoin(Class<T> classOfT, String regex, Condition cnd) {
    Pojo pojo = pojoMaker.makeCountByJoin(holder.getEntity(classOfT), regex).append(Pojos.Items.cnd(cnd)).addParamsBy("*").setAfter(_pojo_fetchInt);
    expert.formatQuery(pojo);
    _exec(pojo);
    return pojo.getInt(0);
}
Also used : Pojo(org.nutz.dao.sql.Pojo)

Example 47 with Pojo

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

the class NutDao method doFetch.

private LinkVisitor doFetch(final EntityOperator opt) {
    return new LinkVisitor() {

        public void visit(final Object obj, final LinkField lnk) {
            Pojo pojo = opt.maker().makeQuery(lnk.getLinkedEntity());
            pojo.setOperatingObject(obj);
            pojo.append(Pojos.Items.cnd(lnk.createCondition(obj)));
            pojo.setAfter(lnk.getCallback());
            _exec(pojo);
            lnk.setValue(obj, pojo.getObject(Object.class));
        }
    };
}
Also used : DoUpdateRelationLinkVisitor(org.nutz.dao.impl.link.DoUpdateRelationLinkVisitor) DoInsertRelationLinkVisitor(org.nutz.dao.impl.link.DoInsertRelationLinkVisitor) DoClearLinkVisitor(org.nutz.dao.impl.link.DoClearLinkVisitor) DoDeleteLinkVisitor(org.nutz.dao.impl.link.DoDeleteLinkVisitor) DoClearRelationByHostFieldLinkVisitor(org.nutz.dao.impl.link.DoClearRelationByHostFieldLinkVisitor) DoUpdateLinkVisitor(org.nutz.dao.impl.link.DoUpdateLinkVisitor) DoInsertLinkVisitor(org.nutz.dao.impl.link.DoInsertLinkVisitor) LinkVisitor(org.nutz.dao.entity.LinkVisitor) DoClearRelationByLinkedFieldLinkVisitor(org.nutz.dao.impl.link.DoClearRelationByLinkedFieldLinkVisitor) Pojo(org.nutz.dao.sql.Pojo) LinkField(org.nutz.dao.entity.LinkField)

Example 48 with Pojo

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

the class NutDao method query.

public List<Record> query(String tableName, Condition cnd, Pager pager, String fields) {
    Pojo pojo = pojoMaker.makeQuery(tableName, fields).addParamsBy(fields).setPager(pager).append(Pojos.Items.cnd(cnd));
    expert.formatQuery(pojo);
    pojo.setAfter(_pojo_queryRecord);
    _exec(pojo);
    return pojo.getList(Record.class);
}
Also used : Pojo(org.nutz.dao.sql.Pojo)

Example 49 with Pojo

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

the class NutDao method clear.

public int clear(Entity<?> entity, Condition cnd) {
    Pojo pojo = pojoMaker.makeDelete(entity).append(Pojos.Items.cnd(cnd));
    _exec(pojo);
    return pojo.getUpdateCount();
}
Also used : Pojo(org.nutz.dao.sql.Pojo)

Example 50 with Pojo

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

the class NutDao method each.

public <T> int each(Entity<T> entity, Condition cnd, Pager pager, Each<T> callback) {
    Pojo pojo = pojoMaker.makeQuery(entity).append(Pojos.Items.cnd(cnd)).addParamsBy("*").setPager(pager).setAfter(_pojo_queryEntity);
    expert.formatQuery(pojo);
    pojo.setAfter(_pojo_eachEntity);
    pojo.getContext().attr(Each.class.getName(), callback);
    pojo.getContext().attr("dao-cache-skip", "true");
    _exec(pojo);
    return pojo.getInt();
}
Also used : Each(org.nutz.lang.Each) Pojo(org.nutz.dao.sql.Pojo)

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