use of org.nutz.dao.sql.PItem in project nutz by nutzam.
the class NutDao method doLinkQuery.
private LinkVisitor doLinkQuery(final EntityOperator opt, final Condition cnd) {
return new LinkVisitor() {
public void visit(final Object obj, final LinkField lnk) {
Pojo pojo = opt.maker().makeQuery(lnk.getLinkedEntity());
pojo.setOperatingObject(obj);
PItem[] _cndItems = Pojos.Items.cnd(lnk.createCondition(obj));
pojo.append(_cndItems);
if (cnd != null) {
if (cnd instanceof Criteria) {
Criteria cri = (Criteria) cnd;
SqlExpressionGroup seg = cri.where();
if (_cndItems.length > 0 && seg != null && !seg.isEmpty()) {
seg.setTop(false);
pojo.append(Pojos.Items.wrap(" AND "));
}
pojo.append(cri);
if (cri.getPager() != null) {
pojo.setPager(cri.getPager());
expert.formatQuery(pojo);
}
} else // 普通条件
{
pojo.append(new ConditionPItem(cnd));
}
}
pojo.setAfter(lnk.getCallback());
pojo.setEntity(lnk.getLinkedEntity());
_exec(pojo);
lnk.setValue(obj, pojo.getResult());
}
};
}
use of org.nutz.dao.sql.PItem in project nutz by nutzam.
the class NutPojoMaker method makeQueryByJoin.
/**
* 按联接进行查询
* @param en
* @param regex
* @return
*/
@Override
public Pojo makeQueryByJoin(final Entity<?> en, String regex) {
final Pojo pojo = Pojos.pojo(expert, en, SqlType.SELECT);
pojo.setEntity(en);
pojo.append(new QueryJoinFeilds(en, true, en.getTableName()));
en.visitOne(null, regex, new LinkVisitor() {
@Override
public void visit(Object obj, LinkField lnk) {
pojo.append(Pojos.Items.wrap(","));
pojo.append(new QueryJoinFeilds(lnk.getLinkedEntity(), false, lnk.getName()));
}
});
pojo.append(Pojos.Items.wrap("FROM"));
pojo.append(Pojos.Items.entityViewName());
en.visitOne(null, regex, new LinkVisitor() {
@Override
public void visit(Object obj, LinkField lnk) {
PItem item = expert.formatLeftJoinLink(obj, lnk, en);
if (item != null)
pojo.append(item);
}
});
return pojo;
}
use of org.nutz.dao.sql.PItem in project nutz by nutzam.
the class NutSql method getParamMatrix.
public Object[][] getParamMatrix() {
int pc = _params_count();
int row_count = rows.size();
if (rows.size() > 1 && params.size() == 0 && rows.get(0).size() != 0) {
row_count--;
}
Object[][] re = new Object[row_count][pc];
for (int z = 0; z < row_count; z++) {
VarSet row = rows.get(z);
int i = 0;
for (PItem item : items) i = item.joinParams(getEntity(), row, re[z], i);
}
return re;
}
use of org.nutz.dao.sql.PItem in project nutz by nutzam.
the class NutSql method _params_count.
protected int _params_count() {
int count = 0;
Entity<?> en = getEntity();
for (PItem item : items) {
count += item.paramCount(en);
}
return count;
}
use of org.nutz.dao.sql.PItem in project nutz by nutzam.
the class NutPojo method _params_count.
private int _params_count() {
if (_pmnum < 0) {
_pmnum = 0;
Entity<?> en = getEntity();
for (PItem item : items) {
_pmnum += item.paramCount(en);
}
}
return _pmnum;
}
Aggregations