Examples of Pojo


Examples of org.nutz.dao.sql.Pojo

  public NutPojoMaker(JdbcExpert expert) {
    this.expert = expert;
  }

  public Pojo makePojo(SqlType type) {
    Pojo pojo = expert.createPojo(type);

    return pojo;
  }
View Full Code Here

Examples of org.nutz.dao.sql.Pojo

    return pojo;
  }

  public Pojo makeInsert(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());
    return pojo;
  }
View Full Code Here

Examples of org.nutz.dao.sql.Pojo

    pojo.append(Pojos.Items.insertValues());
    return pojo;
  }

  public Pojo makeUpdate(Entity<?> en, Object refer) {
    Pojo pojo = Pojos.pojo(expert, en, SqlType.UPDATE);
    pojo.setEntity(en);
    pojo.append(Pojos.Items.entityTableName());
    pojo.append(Pojos.Items.updateFields(refer));
    return pojo;
  }
View Full Code Here

Examples of org.nutz.dao.sql.Pojo

    _exec(pojo);
    return pojo.getObject(classOfT);
  }

  public <T> T fetch(Class<T> classOfT, Condition cnd) {
    Pojo pojo = pojoMaker.makeQuery(holder.getEntity(classOfT))
                .append(Pojos.Items.cnd(cnd))
                .addParamsBy("*")
                .setAfter(_pojo_fetchEntity);
    _exec(pojo);
    return pojo.getObject(classOfT);
  }
View Full Code Here

Examples of org.nutz.dao.sql.Pojo

    _exec(pojo);
    return pojo.getObject(classOfT);
  }

  public Record fetch(String tableName, Condition cnd) {
    Pojo pojo = pojoMaker.makeQuery(tableName)
                .append(Pojos.Items.cnd(cnd))
                .addParamsBy("*")
                .setAfter(_pojo_fetchRecord);
    _exec(pojo);
    return pojo.getObject(Record.class);
  }
View Full Code Here

Examples of org.nutz.dao.sql.Pojo

    pojo.append(Pojos.Items.updateFields(refer));
    return pojo;
  }

  public Pojo makeQuery(Entity<?> en) {
    Pojo pojo = Pojos.pojo(expert, en, SqlType.SELECT);
    pojo.setEntity(en);
    pojo.append(Pojos.Items.queryEntityFields());
    pojo.append(Pojos.Items.wrap("FROM"));
    pojo.append(Pojos.Items.entityViewName());
    return pojo;
  }
View Full Code Here

Examples of org.nutz.dao.sql.Pojo

  }

  @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);
    _exec(pojo);
    return (T) pojo.getResult();
  }
View Full Code Here

Examples of org.nutz.dao.sql.Pojo

    opt.exec();
    return obj;
  }

  public int clear(Class<?> classOfT, Condition cnd) {
    Pojo pojo = pojoMaker.makeDelete(holder.getEntity(classOfT)).append(Pojos.Items.cnd(cnd));
    _exec(pojo);
    return pojo.getUpdateCount();
  }
View Full Code Here

Examples of org.nutz.dao.sql.Pojo

    _exec(pojo);
    return pojo.getUpdateCount();
  }

  public int clear(String tableName, Condition cnd) {
    Pojo pojo = pojoMaker.makeDelete(tableName).append(Pojos.Items.cnd(cnd));
    _exec(pojo);
    return pojo.getUpdateCount();
  }
View Full Code Here

Examples of org.nutz.dao.sql.Pojo

  }

  private int _count(Entity<?> en, String tableName, Condition cnd) {
    // 如果有条件的话
    if (null != cnd) {
      Pojo pojo = pojoMaker.makeFunc(tableName, "COUNT", "*");
      pojo.setEntity(en);
      // 高级条件接口,直接得到 WHERE 子句
      if (cnd instanceof Criteria) {
        pojo.append(((Criteria) cnd).where());
      }
      // 否则暴力获取 WHERE 子句
      else {
        String str = Pojos.formatCondition(en, cnd);
        if (!Strings.isBlank(str)) {
          String[] ss = str.toUpperCase().split("ORDER BY");
          pojo.append(Pojos.Items.wrap(str.substring(0, ss[0].length())));
        }
      }
      // 设置回调,并执行 SQL
      pojo.setAfter(_pojo_fetchInt);
      _exec(pojo);
      return pojo.getInt();
    }
    // 没有条件,直接生成表达式
    return func(tableName, "COUNT", "*");
  }
 
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.