Package org.nutz.dao.entity

Examples of org.nutz.dao.entity.MappingField


            throw new DaoException("expect @Id but NOT found. " + en.getType().getName());
      return cndColumn(mappingField, id);
    }

    public static PItem cndName(Entity<?> en, String name) {
        MappingField mappingField = en.getNameField();
            if (mappingField == null)
                throw new DaoException("expect @Name but NOT found. " + en.getType().getName());
      return cndColumn(mappingField, name);
    }
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

    }

    @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

        else
            sb.append(_fmtcol(en)).append(' ').append(op).append(' ').append('?');
    }

    public int joinAdaptor(Entity<?> en, ValueAdaptor[] adaptors, int off) {
        MappingField mf = _field(en);
        if (null != mf) {
            adaptors[off++] = mf.getAdaptor();
        } else {
            adaptors[off++] = Jdbcs.getAdaptorBy(value);
        }
        return off;
    }
View Full Code Here

            else
              sb.append(index.getName());
            sb.append(" ON ").append(en.getTableName()).append("(");
            for (EntityField field : index.getFields()) {
                if (field instanceof MappingField) {
                    MappingField mf = (MappingField) field;
                    sb.append(mf.getColumnName()).append(',');
                } else {
                    throw Lang.makeThrow(    DaoException.class,
                                            "%s %s is NOT a mapping field, can't use as index field!!",
                                            en.getClass(),
                                            field.getName());
View Full Code Here

    }

    public int joinAdaptor(Entity<?> en, ValueAdaptor[] adaptors, int off) {
        Chain c = chain.head();
        while (c != null) {
            MappingField mf = en.getField(c.name());
            // TODO 移除这种数组下标用++的写法!!!
            if (c.adaptor() == null)
                adaptors[off++] = (null == mf ? Jdbcs.getAdaptorBy(c.value()) : mf.getAdaptor());
            else
                adaptors[off++] = c.adaptor();
            c = c.next();
        }
        return off;
View Full Code Here

    public static PItem queryEntityFields() {
      return new QueryEntityFieldsPItem();
    }

    public static PItem cndId(Entity<?> en, Number id) {
        MappingField mappingField = en.getIdField();
        if (mappingField == null)
            throw new DaoException("expect @Id but NOT found. " + en.getType().getName());
      return cndColumn(mappingField, id);
    }
View Full Code Here

            throw new DaoException("expect @Id but NOT found. " + en.getType().getName());
      return cndColumn(mappingField, id);
    }

    public static PItem cndName(Entity<?> en, String name) {
        MappingField mappingField = en.getNameField();
            if (mappingField == null)
                throw new DaoException("expect @Name but NOT found. " + en.getType().getName());
      return cndColumn(mappingField, name);
    }
View Full Code Here

    public int size() {
        return ext.size();
    }

    public Context set(String name, Object value) {
        MappingField field = en.getField(name);
        if (field != null)
            field.setValue(obj, value);
        else
            ext.put(name, value);
        return this;
    }
View Full Code Here

    }

    public Object get(String name) {
        if (ME.equals(name))
            return obj;
        MappingField field = en.getField(name);
        if (field != null)
            return field.getValue(obj);
        return ext.get(name);
    }
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.