Search in sources :

Example 16 with Pojo

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

the class EntityOperator method addUpdateForIgnoreNull.

public List<Pojo> addUpdateForIgnoreNull(final Entity<?> en, final Object obj, final FieldMatcher fm) {
    if (null == en)
        return null;
    final FieldMatcher newFM;
    if (null == fm)
        newFM = FieldMatcher.make(null, null, true);
    else {
        newFM = fm;
        newFM.setIgnoreNull(true);
    }
    final List<Pojo> re = new ArrayList<Pojo>(Lang.length(obj));
    Lang.each(obj, new Each<Object>() {

        public void invoke(int i, Object ele, int length) throws ExitLoop, LoopException {
            Pojo pojo = dao.pojoMaker.makeUpdate(en, ele).append(Pojos.Items.cndAuto(en, ele)).setOperatingObject(ele);
            pojo.getContext().setFieldMatcher(newFM);
            re.add(pojo);
        }
    });
    pojoList.addAll(re);
    return re;
}
Also used : Pojo(org.nutz.dao.sql.Pojo) ExitLoop(org.nutz.lang.ExitLoop) LoopException(org.nutz.lang.LoopException) ArrayList(java.util.ArrayList) FieldMatcher(org.nutz.dao.FieldMatcher)

Example 17 with Pojo

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

the class EntityOperator method addDeleteSelfOnly.

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

Example 18 with Pojo

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

the class NutDao method each.

public <T> int each(Class<T> classOfT, Condition cnd, Pager pager, Each<T> callback) {
    Pojo pojo = pojoMaker.makeQuery(holder.getEntity(classOfT)).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)

Example 19 with Pojo

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

the class DerbyJdbcExpert method fetchPojoId.

public Pojo fetchPojoId(Entity<?> en, MappingField idField) {
    String autoSql = "select IDENTITY_VAL_LOCAL() as id from " + en.getTableName();
    Pojo autoInfo = new SqlFieldMacro(idField, autoSql);
    autoInfo.setEntity(en);
    return autoInfo;
}
Also used : Pojo(org.nutz.dao.sql.Pojo) SqlFieldMacro(org.nutz.dao.impl.entity.macro.SqlFieldMacro)

Example 20 with Pojo

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

the class GBaseJdbcExpert method fetchPojoId.

public Pojo fetchPojoId(Entity<?> en, MappingField idField) {
    String autoSql = "SELECT @@@@IDENTITY";
    Pojo autoInfo = new SqlFieldMacro(idField, autoSql);
    autoInfo.setEntity(en);
    return autoInfo;
}
Also used : Pojo(org.nutz.dao.sql.Pojo) SqlFieldMacro(org.nutz.dao.impl.entity.macro.SqlFieldMacro)

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