Package org.nutz.dao

Examples of org.nutz.dao.FieldMatcher


import org.nutz.lang.Lang;

public class QueryEntityFieldsPItem extends NoParamsPItem {

  public void joinSql(Entity<?> en, StringBuilder sb) {
    FieldMatcher fm = getFieldMatcher();
    if (null == fm) {
      sb.append("* ");
    } else {
      List<MappingField> efs = _en(en).getMappingFields();

      int old = sb.length();

      for (MappingField ef : efs) {
        if (fm.match(ef.getName()))
          sb.append(ef.getColumnName()).append(',');
      }

      if (sb.length() == old)
        throw Lang.makeThrow("No columns be queryed: '%s'", _en(en));
View Full Code Here


  public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
    Entity<?> en = sql.getEntity();
    if (null == en)
      throw Lang.makeThrow("SQL without entity : %s", sql.toString());
    FieldMatcher fmh = sql.getContext().getFieldMatcher();
    if (null == fmh)
      sql.getContext().setFieldMatcher(FieldFilter.get(en.getType()));
    return process(rs, en, sql.getContext());
  }
View Full Code Here

                        final FieldMatcher fm) {

    if (null == en)
      return null;

    final FieldMatcher newFM;
    if (null == fm)
      newFM = FieldMatcher.make(null, null, true);
    else {
      newFM = fm;
      newFM.setIgnoreNull(true);
    }
    final List<Pojo> re = new ArrayList<Pojo>(Lang.length(obj));
    Lang.each(obj, new Each<Object>() {
      public void invoke(int i, Object ele, int length) throws ExitLoop, LoopException {
        Pojo pojo = dao.pojoMaker.makeUpdate(en, ele)
View Full Code Here

    if (Lang.length(value) == 0)
      return;
    if (value instanceof Map<?, ?>)
      value = ((Map<?, ?>) value).values();

    FieldMatcher fm = FieldFilter.get(lnk.getLinkedEntity().getType());

    // 如果需要忽略 Null 字段,则为每个 POJO 都生成一条语句
    if (null != fm && fm.isIgnoreNull()) {
      opt.addUpdateForIgnoreNull(lnk.getLinkedEntity(), value, fm);
    }
    // 否则生成一条批处理语句
    else {
      opt.addUpdate(lnk.getLinkedEntity(), value);
View Full Code Here

    public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
        Entity<?> en = sql.getEntity();
        if (null == en)
            throw Lang.makeThrow("SQL without entity : %s", sql.toString());
        FieldMatcher fmh = sql.getContext().getFieldMatcher();
        if (null == fmh)
            sql.getContext().setFieldMatcher(FieldFilter.get(en.getType()));
        return process(rs, en, sql.getContext());
    }
View Full Code Here

import org.nutz.lang.Lang;

public class QueryEntityFieldsPItem extends NoParamsPItem {

    public void joinSql(Entity<?> en, StringBuilder sb) {
        FieldMatcher fm = getFieldMatcher();
        if (null == fm) {
            sb.append("* ");
        } else {
            List<MappingField> efs = _en(en).getMappingFields();

            int old = sb.length();

            for (MappingField ef : efs) {
                if (fm.match(ef.getName()))
                    sb.append(ef.getColumnName()).append(',');
            }

            if (sb.length() == old)
                throw Lang.makeThrow("No columns be queryed: '%s'", _en(en));
View Full Code Here

                                                final FieldMatcher fm) {

        if (null == en)
            return null;

        final FieldMatcher newFM;
        if (null == fm)
            newFM = FieldMatcher.make(null, null, true);
        else {
            newFM = fm;
            newFM.setIgnoreNull(true);
        }
        final List<Pojo> re = new ArrayList<Pojo>(Lang.length(obj));
        Lang.each(obj, new Each<Object>() {
            public void invoke(int i, Object ele, int length) throws ExitLoop, LoopException {
                Pojo pojo = dao.pojoMaker.makeUpdate(en, ele)
View Full Code Here

        if (Lang.length(value) == 0)
            return;
        if (value instanceof Map<?, ?>)
            value = ((Map<?, ?>) value).values();

        FieldMatcher fm = FieldFilter.get(lnk.getLinkedEntity().getType());

        // 如果需要忽略 Null 字段,则为每个 POJO 都生成一条语句
        if (null != fm && fm.isIgnoreNull()) {
            opt.addUpdateForIgnoreNull(lnk.getLinkedEntity(), value, fm);
        }
        // 否则生成一条批处理语句
        else {
            opt.addUpdate(lnk.getLinkedEntity(), value);
View Full Code Here

TOP

Related Classes of org.nutz.dao.FieldMatcher

Copyright © 2018 www.massapicom. 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.