Package org.apache.openjpa.meta

Examples of org.apache.openjpa.meta.FieldMetaData$MemberProvider


    /**
     * Set a field's fetch group.
     */
    private void parseFetchAttribute(ClassMetaData meta,
        org.apache.openjpa.meta.FetchGroup fg, FetchAttribute attr) {
        FieldMetaData field = meta.getDeclaredField(attr.name());
        if (field == null
            || field.getManagement() != FieldMetaData.MANAGE_PERSISTENT)
            throw new MetaDataException(_loc.get("bad-fg-field", fg.getName(),
                meta, attr.name()));

        field.setInFetchGroup(fg.getName(), true);
        if (attr.recursionDepth() != Integer.MIN_VALUE)
            fg.setRecursionDepth(field, attr.recursionDepth());
    }
View Full Code Here


        if (meta.isOpenJPAIdentity()) {
            // use meta type instead of oid type in case it's a subclass
            Class cls = meta.getDescribedType();
            OpenJPAId koid = (OpenJPAId) oid;
            FieldMetaData pk = meta.getPrimaryKeyFields()[0];
            switch (pk.getObjectIdFieldTypeCode()) {
                case JavaTypes.BYTE:
                case JavaTypes.BYTE_OBJ:
                    return new ByteId(cls, ((ByteId) oid).getId(),
                        koid.hasSubclasses());
                case JavaTypes.CHAR:
                case JavaTypes.CHAR_OBJ:
                    return new CharId(cls, ((CharId) oid).getId(),
                        koid.hasSubclasses());
                case JavaTypes.DOUBLE:
                case JavaTypes.DOUBLE_OBJ:
                    return new DoubleId(cls, ((DoubleId) oid).getId(),
                        koid.hasSubclasses());
                case JavaTypes.FLOAT:
                case JavaTypes.FLOAT_OBJ:
                    return new FloatId(cls, ((FloatId) oid).getId(),
                        koid.hasSubclasses());
                case JavaTypes.INT:
                case JavaTypes.INT_OBJ:
                    return new IntId(cls, ((IntId) oid).getId(),
                        koid.hasSubclasses());
                case JavaTypes.LONG:
                case JavaTypes.LONG_OBJ:
                    return new LongId(cls, ((LongId) oid).getId(),
                        koid.hasSubclasses());
                case JavaTypes.SHORT:
                case JavaTypes.SHORT_OBJ:
                    return new ShortId(cls, ((ShortId) oid).getId(),
                        koid.hasSubclasses());
                case JavaTypes.STRING:
                    return new StringId(cls, oid.toString(),
                        koid.hasSubclasses());
                case JavaTypes.OID:
                    ClassMetaData embed = pk.getEmbeddedMetaData();
                    Object inner = koid.getIdObject();
                    if (embed != null)
                        inner = copy(inner, embed, embed.getFields());
                    return new ObjectId(cls, inner, koid.hasSubclasses());
                case JavaTypes.OBJECT:
View Full Code Here

        if (!meta.isOpenJPAIdentity()) {
            pc.pcCopyKeyFieldsToObjectId(oid);
            return oid;
        }

        FieldMetaData pk = meta.getPrimaryKeyFields()[0];
        if (pk.getDeclaredTypeCode() != JavaTypes.OID)
            return oid;

        // always copy oid object in case field value mutates or becomes
        // managed
        ObjectId objid = (ObjectId) oid;
        ClassMetaData embed = pk.getEmbeddedMetaData();
        objid.setId(copy(objid.getId(), embed, embed.getFields()));
        return objid;
    }
View Full Code Here

        // already saved?
        if (_saved != null && _saved.get(field))
            return false;

        FieldMetaData fmd = _sm.getMetaData().getField(field);
        boolean mutable = false;
        switch (fmd.getDeclaredTypeCode()) {
            case JavaTypes.DATE:
            case JavaTypes.ARRAY:
            case JavaTypes.COLLECTION:
            case JavaTypes.MAP:
            case JavaTypes.OBJECT:
                mutable = true;
        }

        // if this is not an inverse field and the proper restore flag is
        // not set, skip it

        if (_sm.getBroker().getInverseManager() == null
            || fmd.getInverseMetaDatas().length == 0) {
            // use sm's restore directive, not broker's
            int restore = _sm.getBroker().getRestoreState();
            if (restore == RestoreState.RESTORE_NONE
                || (mutable && restore == RestoreState.RESTORE_IMMUTABLE)) {
                _unloaded.set(field);
View Full Code Here

    public void storeObjectField(int field, Object curVal) {
        // copy mutable fields
        ProxyManager proxy = _sm.getBroker().getConfiguration().
            getProxyManagerInstance();
        FieldMetaData fmd = _sm.getMetaData().getField(field);
        switch (fmd.getDeclaredTypeCode()) {
            case JavaTypes.ARRAY:
                _field = proxy.copyArray(curVal);
                break;
            case JavaTypes.COLLECTION:
                _field = proxy.copyCollection((Collection) curVal);
View Full Code Here

            if (val.isVariable())
                return;

            Class type;
            if (val instanceof Path) {
                FieldMetaData fmd = ((Path) val).last();
                type = (fmd == null) ? val.getType() : fmd.getDeclaredType();
            } else
                type = val.getType();

            switch (JavaTypes.getTypeCode(type)) {
                case JavaTypes.ARRAY:
View Full Code Here

        }

        private Object retrieve(int field) {
            Object val = _store[_index++];
            if (_meta != null) {
                FieldMetaData fmd = _meta.getField(field);
                if (fmd.getDeclaredTypeCode() != JavaTypes.PC)
                    val = JavaTypes.convert(val, fmd.getDeclaredTypeCode());
                else
                    val = JavaTypes.convert(val, JavaTypes.getTypeCode(fmd.
                        getObjectIdFieldType()));
            }
            return val;
    }
View Full Code Here

    public boolean isDefaultValue(int field) {
        Object val = getValue(field);
        if (val == null)
            return true;

        FieldMetaData fmd = getMetaData().getField(field);
        switch (fmd.getDeclaredTypeCode()) {
            case JavaTypes.BOOLEAN:
                return Boolean.FALSE.equals(val);
            case JavaTypes.CHAR:
                return ((Character) val).charValue() == 0;
            case JavaTypes.BYTE:
View Full Code Here

    /**
     * Return the default value of the given field based on its type.
     */
    private Object getDefaultValue(int field) {
        FieldMetaData fmd = getMetaData().getField(field);
        switch (fmd.getDeclaredTypeCode()) {
            case JavaTypes.BOOLEAN:
                return Boolean.FALSE;
            case JavaTypes.BYTE:
                return ZERO_BYTE;
            case JavaTypes.CHAR:
View Full Code Here

     */
    private Object getValue(int field) {
        if (_oid == null)
            return null;

        FieldMetaData fmd = getMetaData().getField(field);
        if (fmd.getBackingMember() instanceof Field)
            return Reflection.get(_oid, (Field) fmd.getBackingMember());
        if (fmd.getBackingMember() instanceof Method)
            return Reflection.get(_oid, (Method) fmd.getBackingMember());

        if (fmd.getDefiningMetaData().getAccessType()
            == ClassMetaData.ACCESS_FIELD)
            return Reflection.get(_oid, Reflection.findField(_oid.getClass(),
                fmd.getName(), true));
        return Reflection.get(_oid, Reflection.findGetter(_oid.getClass(),
            fmd.getName(), true));
    }
View Full Code Here

TOP

Related Classes of org.apache.openjpa.meta.FieldMetaData$MemberProvider

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.