use of org.nutz.dao.sql.Pojo in project nutz by nutzam.
the class NutPojoMaker method makeCountByJoin.
@Override
public Pojo makeCountByJoin(final Entity<?> en, String regex) {
final Pojo pojo = Pojos.pojo(expert, en, SqlType.SELECT);
pojo.setEntity(en);
pojo.append(Pojos.Items.wrap("count(1)"));
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.Pojo in project nutz by nutzam.
the class Sqlserver2005JdbcExpert method fetchPojoId.
public Pojo fetchPojoId(Entity<?> en, MappingField idField) {
String autoSql = "SELECT @@@@IDENTITY as $field";
Pojo autoInfo = new SqlFieldMacro(idField, autoSql);
autoInfo.setEntity(en);
return autoInfo;
}
use of org.nutz.dao.sql.Pojo in project nutz by nutzam.
the class DoDeleteLinkVisitor method visit.
public void visit(Object obj, LinkField lnk) {
Object value = lnk.getValue(obj);
if (value == null || Lang.eleSize(value) == 0) {
log.infof("Value of LinkField(@%s-->%s.%s) is null or isEmtry, ingore", lnk.getLinkType(), lnk.getEntity().getType().getSimpleName(), lnk.getHostField().getName());
return;
}
final Pojo pojo = opt.maker().makeDelete(lnk.getLinkedEntity());
pojo.setOperatingObject(value);
pojo.append(Pojos.Items.cndAuto(lnk.getLinkedEntity(), null));
Lang.each(value, new Each<Object>() {
public void invoke(int i, Object ele, int length) throws ExitLoop, LoopException {
pojo.addParamsBy(ele);
}
});
opt.add(pojo);
}
use of org.nutz.dao.sql.Pojo in project nutz by nutzam.
the class NutPojoMaker method makeFunc.
@Override
public Pojo makeFunc(String tableName, String funcName, String colName) {
Pojo pojo = makePojo(SqlType.SELECT);
pojo.append(Pojos.Items.wrapf("%s(%s) FROM %s", funcName, colName, tableName));
return pojo;
}
use of org.nutz.dao.sql.Pojo in project nutz by nutzam.
the class NutPojoMaker method makeInsert.
@Override
public Pojo makeInsert(final Entity<?> en) {
Pojo pojo = Pojos.pojo(expert, en, SqlType.INSERT);
pojo.setEntity(en);
pojo.append(Pojos.Items.entityTableName());
pojo.append(Pojos.Items.insertFields());
pojo.append(Pojos.Items.insertValues());
if (expert.isSupportAutoIncrement()) {
MappingField mf = en.getIdField();
if (mf != null && mf.isAutoIncreasement()) {
if (expert.isSupportGeneratedKeys()) {
pojo.setAfter(new GeneratedKeys());
pojo.getContext().attr("RETURN_GENERATED_KEYS", true);
}
}
}
return pojo;
}
Aggregations