Search in sources :

Example 6 with Pojo

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

the class NutDao method fetch.

public Record fetch(String tableName, Condition cnd, String fields) {
    Pojo pojo = pojoMaker.makeQuery(tableName).append(Pojos.Items.cnd(cnd)).addParamsBy(fields).setPager(createPager(1, 1)).setAfter(_pojo_fetchRecord);
    expert.formatQuery(pojo);
    _exec(pojo);
    return pojo.getObject(Record.class);
}
Also used : Pojo(org.nutz.dao.sql.Pojo)

Example 7 with Pojo

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

the class NutDao method fetch.

@SuppressWarnings("unchecked")
public <T> T fetch(T obj) {
    Entity<?> en = holder.getEntityBy(obj);
    Pojo pojo = pojoMaker.makeQuery(en).append(Pojos.Items.cndAuto(en, obj)).setAfter(_pojo_fetchEntity).setPager(createPager(1, 1));
    _exec(pojo);
    return (T) pojo.getResult();
}
Also used : Pojo(org.nutz.dao.sql.Pojo)

Example 8 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, String name) {
    if (name == null)
        throw new IllegalArgumentException("name MUST NOT NULL!");
    Entity<T> en = holder.getEntity(classOfT);
    if (en.getNameField() == null)
        throw new DaoException("Need @Name for " + classOfT);
    Pojo pojo = pojoMaker.makeQuery(en).append(Pojos.Items.cndName(en, name)).addParamsBy(name).setAfter(_pojo_fetchEntity);
    _exec(pojo);
    return pojo.getObject(classOfT);
}
Also used : Pojo(org.nutz.dao.sql.Pojo) DaoException(org.nutz.dao.DaoException)

Example 9 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, Condition cnd) {
    Pojo pojo = pojoMaker.makeQuery(holder.getEntity(classOfT)).append(Pojos.Items.cnd(cnd)).addParamsBy("*").setPager(createPager(1, 1)).setAfter(_pojo_fetchEntity);
    expert.formatQuery(pojo);
    _exec(pojo);
    return pojo.getObject(classOfT);
}
Also used : Pojo(org.nutz.dao.sql.Pojo)

Example 10 with Pojo

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

the class NutDao method clear.

public int clear(String tableName, Condition cnd) {
    Pojo pojo = pojoMaker.makeDelete(tableName).append(Pojos.Items.cnd(cnd));
    _exec(pojo);
    return pojo.getUpdateCount();
}
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