Package org.nutz.dao.entity

Examples of org.nutz.dao.entity.MappingField


    protected String _fmtcolnm(Entity<?> en, String name) {
        if (null == en && null != pojo)
            en = pojo.getEntity();

        if (null != en) {
            MappingField mf = en.getField(name);
            if (null != mf)
                return mf.getColumnName();
        }
        return name;
    }
View Full Code Here


        final StringBuilder sql = new StringBuilder("UPDATE ").append(tableName).append(" SET ");
        Chain head = chain.head();
        final List<Object> values = new ArrayList<Object>();
        final List<ValueAdaptor> adaptors = new ArrayList<ValueAdaptor>();
        while (head != null) {
            MappingField mf = null;
            if (en != null)
                mf = en.getField(head.name());
            String colName = head.name();
            if (mf != null)
                colName = mf.getColumnName();
            sql.append(colName).append("=");
            if (head.special()) {
              if (head.value() != null && head.value() instanceof String) {
                String str = (String)head.value();
                if (str.length() > 0) {
                  switch (str.charAt(0)) {
            case '+':
            case '-':
            case '*':
            case '/':
            case '%':
            case '&':
            case '^':
            case '|':
              sql.append(colName);
              break;
            }
                }
                }
                sql.append(head.value());
            } else {
                sql.append("?");
                values.add(head.value());
                ValueAdaptor adaptor = Jdbcs.getAdaptorBy(head.value());
                if (mf != null && mf.getAdaptor() != null)
                    adaptor = mf.getAdaptor();
                adaptors.add(adaptor);
            }
            sql.append(" ");
            head = head.next();
            if (head != null)
View Full Code Here

        final List<Object> values = new ArrayList<Object>();
        final List<ValueAdaptor> adaptors = new ArrayList<ValueAdaptor>();
        Chain head = chain.head();
        while (head != null) {
          String colName = head.name();
          MappingField mf = null;
            if (en != null) {
                mf = en.getField(colName);
                if (mf != null)
                  colName = mf.getColumnName();
            }
            sql.append(colName);
           
            if (head.special()) {
              _value_places.append(head.value());
            } else {
                if (en != null)
                    mf = en.getField(head.name());
                _value_places.append("?");
                values.add(head.value());
                ValueAdaptor adaptor = Jdbcs.getAdaptorBy(head.value());
                if (mf != null && mf.getAdaptor() != null)
                    adaptor = mf.getAdaptor();
                adaptors.add(adaptor);
            }
           
            head = head.next();
            if (head != null) {
View Full Code Here

    }

    @Test
    public void test_override_field() {
        Entity<?> en = en(Pet2.class);
        MappingField ef = en.getField("nickName");
        assertEquals("alias", ef.getColumnName());
        assertEquals(1, en.cloneBeforeInsertMacroes().size());
    }
View Full Code Here

        }
        public Chain updateBy(Entity<?> entity) {
            if (null != entity) {
                Entry current = head;
                while (current != null) {
                    MappingField ef = entity.getField(current.name);
                    if (null != ef) {
                        current.name = ef.getColumnName();
                    }
                    current = current.next;
                }
            }
            return head();
View Full Code Here

    public int paramCount(Entity<?> en) {
        return values.length;
    }

    private String _colname(Entity<?> en, int index) {
      MappingField field = en.getField(names[index]);
      if (field == null)
        throw new IllegalArgumentException(String.format("Class %s didn't have field named (%s)", en.getType(), names[index]));
        return field.getColumnName();
    }
View Full Code Here

TOP

Related Classes of org.nutz.dao.entity.MappingField

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.