Package javax.persistence.spi

Examples of javax.persistence.spi.PersistenceUnitInfo


                    "Persistence units defined by the bundle will not be available until the bundle is refreshed");
            throw new InvalidPersistenceUnitException();
          }
     
          for(ManagedPersistenceUnitInfo info : persistenceUnits){
            PersistenceUnitInfo pUnitInfo = info.getPersistenceUnitInfo();
       
            emfs.put(pUnitInfo.getPersistenceUnitName(),
                providerService.createContainerEntityManagerFactory(
                    pUnitInfo, info.getContainerProperties()));
          }
        } finally {
          //Remember to unget the provider
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

            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

    }
    if (this.persistenceUnitInfos.size() > 1) {
      throw new IllegalStateException("No single default persistence unit defined in " +
          ObjectUtils.nullSafeToString(this.persistenceXmlLocations));
    }
    PersistenceUnitInfo pui = this.persistenceUnitInfos.values().iterator().next();
    this.persistenceUnitInfos.clear();
    return pui;
  }
View Full Code Here

    this.persistenceUnitInfos.clear();
    return pui;
  }

  public PersistenceUnitInfo obtainPersistenceUnitInfo(String persistenceUnitName) {
    PersistenceUnitInfo pui = this.persistenceUnitInfos.remove(persistenceUnitName);
    if (pui == null) {
      if (!this.persistenceUnitInfoNames.contains(persistenceUnitName)) {
        throw new IllegalArgumentException(
            "No persistence unit with name '" + persistenceUnitName + "' found");
      }
View Full Code Here

        new PathMatchingResourcePatternResolver(), dataSourceLookup);
    PersistenceUnitInfo[] info = reader.readPersistenceUnitInfos(resource);

    assertEquals(2, info.length);

    PersistenceUnitInfo pu1 = info[0];

    assertEquals("pu1", pu1.getPersistenceUnitName());

    assertEquals("com.acme.AcmePersistence", pu1.getPersistenceProviderClassName());

    assertEquals(1, pu1.getMappingFileNames().size());
    assertEquals("ormap2.xml", pu1.getMappingFileNames().get(0));

    assertEquals(1, pu1.getJarFileUrls().size());
    assertEquals(new ClassPathResource("order.jar").getURL(), pu1.getJarFileUrls().get(0));

    // TODO need to check the default? Where is this defined
    assertFalse(pu1.excludeUnlistedClasses());

    assertSame(PersistenceUnitTransactionType.RESOURCE_LOCAL, pu1.getTransactionType());

    Properties props = pu1.getProperties();
    assertEquals(2, props.keySet().size());
    assertEquals("on", props.getProperty("com.acme.persistence.sql-logging"));
    assertEquals("bar", props.getProperty("foo"));

    assertNull(pu1.getNonJtaDataSource());

    assertSame(ds, pu1.getJtaDataSource());

    PersistenceUnitInfo pu2 = info[1];

    assertSame(PersistenceUnitTransactionType.JTA, pu2.getTransactionType());
    assertEquals("com.acme.AcmePersistence", pu2.getPersistenceProviderClassName());

    assertEquals(1, pu2.getMappingFileNames().size());
    assertEquals("order2.xml", pu2.getMappingFileNames().get(0));

    assertEquals(1, pu2.getJarFileUrls().size());
    assertEquals(new ClassPathResource("order-supplemental.jar").getURL(), pu2.getJarFileUrls().get(0));
    assertTrue(pu2.excludeUnlistedClasses());

    assertNull(pu2.getJtaDataSource());

    // TODO need to define behaviour with non jta datasource
    assertEquals(ds, pu2.getNonJtaDataSource());
  }
View Full Code Here

    }
    if (this.persistenceUnitInfos.size() > 1) {
      throw new IllegalStateException("No single default persistence unit defined in " +
          ObjectUtils.nullSafeToString(this.persistenceXmlLocations));
    }
    PersistenceUnitInfo pui = this.persistenceUnitInfos.values().iterator().next();
    this.persistenceUnitInfos.clear();
    return pui;
  }
View Full Code Here

    this.persistenceUnitInfos.clear();
    return pui;
  }

  public PersistenceUnitInfo obtainPersistenceUnitInfo(String persistenceUnitName) {
    PersistenceUnitInfo pui = this.persistenceUnitInfos.remove(persistenceUnitName);
    if (pui == null) {
      if (!this.persistenceUnitInfoNames.contains(persistenceUnitName)) {
        throw new IllegalArgumentException(
            "No persistence unit with name '" + persistenceUnitName + "' found");
      }
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.