Search in sources :

Example 11 with Pojo

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

the class NutDao method query.

public <T> List<T> query(Class<T> classOfT, Condition cnd, Pager pager) {
    Pojo pojo = pojoMaker.makeQuery(holder.getEntity(classOfT)).append(Pojos.Items.cnd(cnd)).addParamsBy("*").setPager(pager).setAfter(_pojo_queryEntity);
    expert.formatQuery(pojo);
    _exec(pojo);
    return pojo.getList(classOfT);
}
Also used : Pojo(org.nutz.dao.sql.Pojo)

Example 12 with Pojo

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

the class NutDao method fetch.

public <T> T fetch(Class<T> classOfT, long id) {
    Entity<T> en = holder.getEntity(classOfT);
    if (en.getIdField() == null)
        throw new DaoException("Need @Id for " + classOfT);
    Pojo pojo = pojoMaker.makeQuery(en).append(Pojos.Items.cndId(en, id)).addParamsBy(id).setAfter(_pojo_fetchEntity);
    _exec(pojo);
    return pojo.getObject(classOfT);
}
Also used : Pojo(org.nutz.dao.sql.Pojo) DaoException(org.nutz.dao.DaoException)

Example 13 with Pojo

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

the class EntityOperator method addDeleteSelfOnly.

public Pojo addDeleteSelfOnly(String name) {
    if (null == entity)
        return null;
    Pojo pojo = dao.pojoMaker.makeDelete(entity);
    pojo.append(Pojos.Items.cndName(entity, name));
    pojo.addParamsBy(name);
    pojoList.add(pojo);
    return pojo;
}
Also used : Pojo(org.nutz.dao.sql.Pojo)

Example 14 with Pojo

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

the class EntityOperator method addUpdate.

public Pojo addUpdate(final Entity<?> en, final Object obj) {
    if (null == en)
        return null;
    Pojo pojo = dao.pojoMaker.makeUpdate(en, null).append(Pojos.Items.cndAuto(en, Lang.first(obj))).setOperatingObject(obj);
    pojoList.add(pojo);
    return pojo;
}
Also used : Pojo(org.nutz.dao.sql.Pojo)

Example 15 with Pojo

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

the class EntityOperator method addUpdate.

public Pojo addUpdate(Chain chain, Condition cnd) {
    Pojo pojo = dao.pojoMaker.makePojo(SqlType.UPDATE);
    pojo.setEntity(entity);
    pojo.append(Pojos.Items.entityTableName());
    pojo.append(Pojos.Items.updateFieldsBy(chain));
    pojo.append(Pojos.Items.cnd(cnd));
    pojoList.add(pojo);
    return pojo;
}
Also used : Pojo(org.nutz.dao.sql.Pojo)

Aggregations

Pojo (org.nutz.dao.sql.Pojo)49 SqlFieldMacro (org.nutz.dao.impl.entity.macro.SqlFieldMacro)6 ExitLoop (org.nutz.lang.ExitLoop)5 LoopException (org.nutz.lang.LoopException)5 ManyManyLinkField (org.nutz.dao.impl.entity.field.ManyManyLinkField)4 ArrayList (java.util.ArrayList)3 Connection (java.sql.Connection)2 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 Statement (java.sql.Statement)2 Map (java.util.Map)2 DaoException (org.nutz.dao.DaoException)2 LinkField (org.nutz.dao.entity.LinkField)2 LinkVisitor (org.nutz.dao.entity.LinkVisitor)2 DoClearLinkVisitor (org.nutz.dao.impl.link.DoClearLinkVisitor)2 DoClearRelationByHostFieldLinkVisitor (org.nutz.dao.impl.link.DoClearRelationByHostFieldLinkVisitor)2 DoClearRelationByLinkedFieldLinkVisitor (org.nutz.dao.impl.link.DoClearRelationByLinkedFieldLinkVisitor)2 DoDeleteLinkVisitor (org.nutz.dao.impl.link.DoDeleteLinkVisitor)2 DoInsertLinkVisitor (org.nutz.dao.impl.link.DoInsertLinkVisitor)2 DoInsertRelationLinkVisitor (org.nutz.dao.impl.link.DoInsertRelationLinkVisitor)2