Package org.apache.openjpa.meta

Examples of org.apache.openjpa.meta.MetaDataRepository


     */
    private void evictTypes(Collection<Class<?>> classes) {
        if (classes.isEmpty())
            return;

        MetaDataRepository mdr = _ctx.getConfiguration().getMetaDataRepositoryInstance();
        ClassLoader loader = _ctx.getClassLoader();

        DataCache cache;
        for (Class<?> cls : classes) {
            cache = mdr.getMetaData(cls, loader, false).getDataCache();
            if (cache != null && cache.getEvictOnBulkUpdate())
                cache.removeAll(cls, false);
        }
    }
View Full Code Here


            // setup transient state
            setup();

            // register the metdata repository to auto-load persistent types
            // and make sure types are enhanced
            MetaDataRepository repos = _conf.getMetaDataRepositoryInstance();
            repos.setValidate(MetaDataRepository.VALIDATE_RUNTIME, true);
            repos.setResolve(MetaDataModes.MODE_MAPPING_INIT, true);
            PCRegistry.addRegisterClassListener(repos);

            // freeze underlying configuration and eagerly initialize to
            // avoid synchronization
            _conf.setReadOnly(Configuration.INIT_STATE_FREEZING);
View Full Code Here

                _conf.isConnectionFactoryModeManaged(), _conf.getConnectionRetainModeConstant(), false).close();
        }
        // Don't catch any exceptions here because we want to fail-fast if something bad happens when we're preloading.
        Options o = Configurations.parseProperties(Configurations.getProperties(_conf.getMetaDataRepository()));
        if (MetaDataRepository.needsPreload(o) == true) {
            MetaDataRepository mdr = _conf.getMetaDataRepositoryInstance();
            mdr.setValidate(MetaDataRepository.VALIDATE_RUNTIME, true);
            mdr.setResolve(MetaDataRepository.MODE_MAPPING_INIT, true);

            // Load persistent classes and hook in subclasser
            loadPersistentTypes((ClassLoader) AccessController.doPrivileged(J2DoPrivHelper
                .getContextClassLoaderAction()));
            mdr.preload();
        }

        // Get a DataCacheManager instance up front to avoid threading concerns on first call.
        // _conf.getDataCacheManagerInstance();
View Full Code Here

        em = emf.createEntityManager();
        root = createData();
    }
   
    public void testDetachCascadeIsSet() {
        MetaDataRepository repos = emf.getConfiguration()
                                      .getMetaDataRepositoryInstance();
        ClassMetaData meta = repos.getCachedMetaData(DMCustomer.class);
        assertEquals(ValueMetaData.CASCADE_NONE,
                meta.getField("firstName").getCascadeDetach());
        assertEquals(ValueMetaData.CASCADE_IMMEDIATE, meta.getField(
                "customerInventories").getElement().getCascadeDetach());
       
        meta = repos.getCachedMetaData(DMCustomerInventory.class);
        assertEquals(ValueMetaData.CASCADE_NONE,
                meta.getField("customer").getCascadeDetach());
        assertEquals(ValueMetaData.CASCADE_NONE,
                meta.getField("item").getCascadeDetach());
       
View Full Code Here

    public void testExplicitEnhancementWithClassNotInFirstPU()
        throws ClassNotFoundException {
        OpenJPAConfiguration conf = new OpenJPAConfigurationImpl();
        Configurations.populateConfiguration(conf, new Options());
        MetaDataRepository repos = conf.getMetaDataRepositoryInstance();
        ClassLoader loader = AccessController
            .doPrivileged(J2DoPrivHelper.newTemporaryClassLoaderAction(
                getClass().getClassLoader()));
        Project project = new Project();
View Full Code Here

        OpenJPAConfiguration conf = new OpenJPAConfigurationImpl();
        Options opts = new Options();
        opts.setProperty("p",
            "META-INF/persistence.xml#second-persistence-unit");
        Configurations.populateConfiguration(conf, opts);
        MetaDataRepository repos = conf.getMetaDataRepositoryInstance();
        ClassLoader loader = AccessController
            .doPrivileged(J2DoPrivHelper.newTemporaryClassLoaderAction(
                getClass().getClassLoader()));
        Project project = new Project();
View Full Code Here

        throws IOException {
        OpenJPAConfiguration conf = new OpenJPAConfigurationImpl();
        Options opts = new Options();
        opts.setProperty("p", "META-INF/persistence.xml");
        Configurations.populateConfiguration(conf, opts);
        MetaDataRepository repos = conf.getMetaDataRepositoryInstance();
        ClassLoader loader = AccessController
            .doPrivileged(J2DoPrivHelper.newTemporaryClassLoaderAction(
                getClass().getClassLoader()));
        Project project = new Project();
View Full Code Here

     * Return a query executor of the proper type.
     */
    private StoreQuery.Executor createExecutor(boolean inMem) {
        assertCandidateType();

        MetaDataRepository repos = _broker.getConfiguration().
            getMetaDataRepositoryInstance();
        ClassMetaData meta = repos.getMetaData(_class,
            _broker.getClassLoader(), false);

        ClassMetaData[] metas;
        if (_class == null || _storeQuery.supportsAbstractExecutors())
            metas = new ClassMetaData[]{ meta };
        else if (_subclasses && (meta == null || meta.isManagedInterface()))
            metas = repos.getImplementorMetaDatas(_class,
                _broker.getClassLoader(), true);
        else if (meta != null && (_subclasses || meta.isMapped()))
            metas = new ClassMetaData[]{ meta };
        else
            metas = StoreQuery.EMPTY_METAS;
View Full Code Here

        if (oids.isEmpty())
            return classes;
        if (classes == null)
            classes = new HashSet();

        MetaDataRepository repos = conf.getMetaDataRepositoryInstance();
        ClassMetaData meta;
        Object oid;
        for (Iterator itr = oids.iterator(); itr.hasNext();) {
            oid = itr.next();
            if (oid instanceof Id)
                classes.add(((Id) oid).getType());
            else {
                // ok if no metadata for oid; that just means the pc type
                // probably hasn't been loaded into this JVM yet, and therefore
                // there's no chance that it's in the cache anyway
                meta = repos.getMetaData(oid, null, false);
                if (meta != null)
                    classes.add(meta.getDescribedType());
            }
        }
        return classes;
View Full Code Here

     */
    public ApplicationIdTool(OpenJPAConfiguration conf, Class type) {
        _log = conf.getLog(OpenJPAConfiguration.LOG_ENHANCE);
        _type = type;

        MetaDataRepository repos = conf.newMetaDataRepositoryInstance();
        repos.setValidate(repos.VALIDATE_NONE);
        repos.setSourceMode(repos.MODE_MAPPING, false);
        loadObjectIds(repos, true);
        _meta = repos.getMetaData(type, null, false);
        if (_meta != null) {
            _abstract = Modifier.isAbstract(_meta.getDescribedType().
                getModifiers());
            _fields = getDeclaredPrimaryKeyFields(_meta);
        }
View Full Code Here

TOP

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

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.