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);
}
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();
}
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);
}
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);
}
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();
}
Aggregations