Package javax.persistence.spi

Examples of javax.persistence.spi.PersistenceUnitInfo


   
    /**
     * INTERNAL:
     */
    protected void loadStandardMappingFiles(String ormXMLFile) {
        PersistenceUnitInfo puInfo = m_project.getPersistenceUnitInfo();
        Collection<URL> rootUrls = new HashSet<URL>(puInfo.getJarFileUrls());
        rootUrls.add(puInfo.getPersistenceUnitRootUrl());
       
        for (URL rootURL : rootUrls) {
            logMessage("Searching for default mapping file in " + rootURL);
            URL ormURL = null;

View Full Code Here


            embeddable.getAccessibleObject().getEntityMappings().processEntityMappingsDefaults(embeddable);
        }
       
        // 4 - Iterate through the classes that are references from the
        // persistence.xml file.
        PersistenceUnitInfo persistenceUnitInfo = m_project.getPersistenceUnitInfo();
        List<String> classNames = new ArrayList<String>();
       
        // Add all the <class> specifications.
        classNames.addAll(persistenceUnitInfo.getManagedClassNames());

        // Add all the classes from the <jar> specifications.
        for (URL url : persistenceUnitInfo.getJarFileUrls()) {
            classNames.addAll(PersistenceUnitProcessor.getClassNamesFromURL(url));
        }

        // Add all the classes off the classpath at the persistence unit root url.
        if (! persistenceUnitInfo.excludeUnlistedClasses()) {
            classNames.addAll(PersistenceUnitProcessor.getClassNamesFromURL(persistenceUnitInfo.getPersistenceUnitRootUrl()));
        }
       
        // 5 - Go through all the class names we found and add those classes
        // that have not yet been added. Be sure to check that the accessor
        // does not already exist since adding an accessor will merge its
View Full Code Here

   
    /**
     * INTERNAL:
     */
    protected void loadSpecifiedMappingFiles(boolean throwExceptionOnFail) {
        PersistenceUnitInfo puInfo = m_project.getPersistenceUnitInfo();
       
        for (String mappingFileName : puInfo.getMappingFileNames()) {
            try {
                Enumeration<URL> mappingFileURLs = m_loader.getResources(mappingFileName);
               
                if (mappingFileURLs.hasMoreElements()) {
                    URL nextURL = mappingFileURLs.nextElement();

                    if (mappingFileURLs.hasMoreElements()) {
                        handleORMException(ValidationException.nonUniqueMappingFileName(puInfo.getPersistenceUnitName(), mappingFileName), mappingFileName, throwExceptionOnFail);
                    }
                   
                    // Read the document through OX and add it to the project.
                    m_project.addEntityMappings(XMLEntityMappingsReader.read(nextURL, m_loader));
                } else {
                    handleORMException(ValidationException.mappingFileNotFound(puInfo.getPersistenceUnitName(), mappingFileName), mappingFileName, throwExceptionOnFail);
                }
            } catch (IOException e) {
                handleORMException(PersistenceUnitLoadingException.exceptionLoadingORMXML(mappingFileName, e), mappingFileName, throwExceptionOnFail);
            }
        }
View Full Code Here

   
    /**
     * INTERNAL:
     */
    protected void loadStandardMappingFiles(String ormXMLFile) {
        PersistenceUnitInfo puInfo = m_project.getPersistenceUnitInfo();
        Collection<URL> rootUrls = new HashSet<URL>(puInfo.getJarFileUrls());
        rootUrls.add(puInfo.getPersistenceUnitRootUrl());
       
        for (URL rootURL : rootUrls) {
            logMessage("Searching for default mapping file in " + rootURL);
            URL ormURL = null;
           
View Full Code Here

            boolean initialized = false;
            while (resources.hasMoreElements()) {
                String puName = PersistenceUnitProcessor.buildPersistenceUnitName(PersistenceUnitProcessor.computePURootURL(resources.nextElement()), name);

                synchronized (EntityManagerFactoryProvider.persistenceUnits) {
                    PersistenceUnitInfo puInfo = EntityManagerFactoryProvider.getPersistenceUnitInfo(puName);
                    if (puInfo == null) {
                        if (!initialized) {
                            initializer.initialize(nonNullProperties, initializationHelper);
                            initialized = true;
                        }
                        puInfo = EntityManagerFactoryProvider.getPersistenceUnitInfo(puName);
                    }
                    if (puInfo != null) {
                        String esiName = puName;
                        if (nonNullProperties.get(PersistenceUnitProperties.SESSION_NAME) != null) {
                            esiName = puName + nonNullProperties.get(PersistenceUnitProperties.SESSION_NAME);
                        } else {
                            if (puInfo.getProperties().get(PersistenceUnitProperties.SESSION_NAME) != null) {
                                esiName = puName + puInfo.getProperties().get(PersistenceUnitProperties.SESSION_NAME);
                            }
                        }
                        emSetupImpl = EntityManagerFactoryProvider.getEntityManagerSetupImpl(esiName);
                        if (emSetupImpl == null) {
                            initializer.callPredeploy(puInfo, nonNullProperties, initializationHelper);
View Full Code Here

            new PersistenceProductDerivation.ConfigurationParser(config);
        try {
            URL url = getResourceURL(persistenceFile);
            cfgParser.parse(url);
            List<PersistenceUnitInfoImpl> units = cfgParser.getResults();
            PersistenceUnitInfo puinf = null;
            // Find the pu info that matches the pu name
            for (PersistenceUnitInfo pui : units) {
                if (pu.equals(pui.getPersistenceUnitName())) {
                    puinf = pui;
                    break;
View Full Code Here

    MergingPersistenceUnitManager manager = new MergingPersistenceUnitManager();
    manager.setPersistenceXmlLocations(new String[] { "classpath:org/springframework/data/jpa/support/persistence.xml",
        "classpath:org/springframework/data/jpa/support/persistence2.xml" });
    manager.preparePersistenceUnitInfos();

    PersistenceUnitInfo info = manager.obtainPersistenceUnitInfo("pu");
    assertThat(info.getManagedClassNames().size(), is(2));
    assertThat(info.getManagedClassNames(), hasItems(User.class.getName(), Role.class.getName()));

    assertThat(info.getMappingFileNames().size(), is(2));
    assertThat(info.getMappingFileNames(), hasItems("foo.xml", "bar.xml"));
  }
View Full Code Here

  protected void postProcessPersistenceUnitInfo(MutablePersistenceUnitInfo pui) {

    // Invoke normal post processing
    super.postProcessPersistenceUnitInfo(pui);

    PersistenceUnitInfo oldPui = getPersistenceUnitInfo(pui.getPersistenceUnitName());

    if (oldPui != null) {
      postProcessPersistenceUnitInfo(pui, oldPui);
    }
  }
View Full Code Here

        setDescription("JPA Configuration");
    }
   
    protected Configuration createConfiguration(MergeFileSystemAndClassPathXMLApplicationContext mergeContext) {
        try {
            PersistenceUnitInfo unitInfo = ((MergePersistenceUnitManager) mergeContext.getBean("blPersistenceUnitManager")).obtainPersistenceUnitInfo(persistenceUnit);
           
            Map<Object, Object> overrides = new HashMap<Object, Object>();
            Properties p = getProperties();
           
            if(p!=null) {
View Full Code Here

        classTransformers.addAll(mergedClassTransformers);
    }

    protected PersistenceUnitInfo getMergedUnit(String persistenceUnitName, MutablePersistenceUnitInfo newPU) {
        if (!mergedPus.containsKey(persistenceUnitName)) {
            PersistenceUnitInfo puiToStore = newPU;
            if (jpa2ApiPresent) {
                puiToStore = createPersistenceUnit(newPU);
            }
            mergedPus.put(persistenceUnitName, puiToStore);
        }
View Full Code Here

TOP

Related Classes of javax.persistence.spi.PersistenceUnitInfo

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.