Package org.apache.openjpa.meta

Examples of org.apache.openjpa.meta.ClassMetaData


        int projs = getContext().getProjectionAliases().length;
        if (projs == 0) {
            // make sure the data cache contains the oids for the query result;
            // if it doesn't, then using the result could be slower than not
            // using it because of the individual by-oid lookups
            ClassMetaData meta = _repos.getMetaData(getContext().
                getCandidateType(), _sctx.getClassLoader(), true);
            BitSet idxs = meta.getDataCache().containsAll(res);

            // eventually we should optimize this to figure out how many objects
            // the cache is missing and if only a few do a bulk fetch for them
            int len = idxs.length();
            if (len < res.size())
View Full Code Here


        return sub ? newUnenhancedSubclassInstance()
            : newUnenhancedInstance();
    }

    public void testMetaData() {
        ClassMetaData meta = JPAFacadeHelper.getMetaData(emf,
            getUnenhancedClass());
        assertEquals(ClassRedefiner.canRedefineClasses(),
            meta.isIntercepting());
    }
View Full Code Here

        assertEquals("updated", listener.stringField);
    }

    public void testGetMetaDataOfSubtype() {
        ClassMetaData meta = JPAFacadeHelper.getMetaData(emf,
            getUnenhancedClass());
        List<Class> subs =  ManagedClassSubclasser.prepareUnenhancedClasses(
            emf.getConfiguration(),
            Collections.singleton(getUnenhancedClass()), null);
        assertSame(meta, JPAFacadeHelper.getMetaData(emf, subs.get(0)));
View Full Code Here

        boolean remove;

        // this logic could be more efficient -- we could aggregate
        // all the cache->oid changes, and then use DataCache.removeAll()
        // and less write locks to do the mutation.
        ClassMetaData meta = sm.getMetaData();
        DataCache cache = meta.getDataCache();
        if (cache == null)
            return;

        cache.writeLock();
        try {
View Full Code Here

    /**
     * Create a new cacheable instance for the given state manager.
     */
    private DataCachePCData newPCData(OpenJPAStateManager sm) {
        ClassMetaData meta = sm.getMetaData();
        if (_gen != null)
            return (DataCachePCData) _gen.generatePCData
                (sm.getObjectId(), meta);
        return new DataCachePCDataImpl(sm.fetchObjectId(), meta);
    }
View Full Code Here

                .SharedName2.class);
        emf.createEntityManager().close();
    }

        public void testMappedSuperclass() {
        ClassMetaData meta = emf.getConfiguration()
            .getMetaDataRepositoryInstance()
            .getMetaData("SharedName1", getClass().getClassLoader(), true);
        assertEquals(
            org.apache.openjpa.persistence.inheritance.entity.SharedName1.class,
            meta.getDescribedType());
    }
View Full Code Here

            org.apache.openjpa.persistence.inheritance.entity.SharedName1.class,
            meta.getDescribedType());
    }

    public void testEmbeddable() {
        ClassMetaData meta = emf.getConfiguration()
            .getMetaDataRepositoryInstance()
            .getMetaData("SharedName2", getClass().getClassLoader(), true);
        assertEquals(
            org.apache.openjpa.persistence.inheritance.entity.SharedName2.class,
            meta.getDescribedType());
    }
View Full Code Here

            throw SQLExceptions.getStore(se, _dict);
        }
    }

    public boolean assignObjectId(OpenJPAStateManager sm, boolean preFlush) {
        ClassMetaData meta = sm.getMetaData();
        if (meta.getIdentityType() == ClassMetaData.ID_APPLICATION)
            return ApplicationIds.assign(sm, this, preFlush);

        // datastore identity
        Object val = ImplHelper.generateIdentityValue(_ctx, meta,
            JavaTypes.LONG);
        if (val == null && meta.getIdentityStrategy() != ValueStrategies.NATIVE)
            return false;
        if (val == null)
            val = getDataStoreIdSequence(meta).next(_ctx, meta);
        sm.setObjectId(newDataStoreId(val, meta));
        return true;
View Full Code Here

        if (cls == null)
            return null;

        beginOperation(false);
        try {
            ClassMetaData meta = _conf.getMetaDataRepositoryInstance().
                getMetaData(cls, _loader, false);
            if (meta == null
                || meta.getIdentityType() == ClassMetaData.ID_UNKNOWN)
                return null;
            if (meta.getIdentityType() == ClassMetaData.ID_APPLICATION)
                return meta.getObjectIdType();

            return _store.getDataStoreIdType(meta);
        } catch (OpenJPAException ke) {
            throw ke;
        } catch (RuntimeException re) {
View Full Code Here

        if (val == null)
            return null;

        beginOperation(false);
        try {
            ClassMetaData meta = _conf.getMetaDataRepositoryInstance().
                getMetaData(cls, _loader, true);
            switch (meta.getIdentityType()) {
            case ClassMetaData.ID_DATASTORE:
                // delegate to store manager for datastore ids
                if (val instanceof String
                    && ((String) val).startsWith(StateManagerId.STRING_PREFIX))
                    return new StateManagerId((String) val);
                return _store.newDataStoreId(val, meta);
            case ClassMetaData.ID_APPLICATION:
                if (ImplHelper.isAssignable(meta.getObjectIdType(),
                    val.getClass())) {
                    if (!meta.isOpenJPAIdentity()
                        && meta.isObjectIdTypeShared())
                        return new ObjectId(cls, val);
                    return val;
                }

                // stringified app id?
View Full Code Here

TOP

Related Classes of org.apache.openjpa.meta.ClassMetaData

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.