@Override public List<String> getMappingFileNames() { return persistenceUnitInfo.getMappingFileNames(); }
for (String mappingFileName : oldPui.getMappingFileNames()) { if (!pui.getMappingFileNames().contains(mappingFileName)) { LOG.debug("Adding mapping file to persistence unit {}.", mappingFileName, persistenceUnitName);
@Test public void testExample2() throws Exception { PersistenceUnitReader reader = new PersistenceUnitReader( new PathMatchingResourcePatternResolver(), new JndiDataSourceLookup()); String resource = "/org/springframework/orm/jpa/persistence-example2.xml"; PersistenceUnitInfo[] info = reader.readPersistenceUnitInfos(resource); assertNotNull(info); assertEquals(1, info.length); assertEquals("OrderManagement2", info[0].getPersistenceUnitName()); assertEquals(1, info[0].getMappingFileNames().size()); assertEquals("mappings.xml", info[0].getMappingFileNames().get(0)); assertEquals(0, info[0].getProperties().keySet().size()); assertFalse("Exclude unlisted should default false in 1.0.", info[0].excludeUnlistedClasses()); }
@Test public void testExample5() throws Exception { PersistenceUnitReader reader = new PersistenceUnitReader( new PathMatchingResourcePatternResolver(), new JndiDataSourceLookup()); String resource = "/org/springframework/orm/jpa/persistence-example5.xml"; PersistenceUnitInfo[] info = reader.readPersistenceUnitInfos(resource); assertNotNull(info); assertEquals(1, info.length); assertEquals("OrderManagement5", info[0].getPersistenceUnitName()); assertEquals(2, info[0].getMappingFileNames().size()); assertEquals("order1.xml", info[0].getMappingFileNames().get(0)); assertEquals("order2.xml", info[0].getMappingFileNames().get(1)); assertEquals(2, info[0].getJarFileUrls().size()); assertEquals(new ClassPathResource("order.jar").getURL(), info[0].getJarFileUrls().get(0)); assertEquals(new ClassPathResource("order-supplemental.jar").getURL(), info[0].getJarFileUrls().get(1)); assertEquals("com.acme.AcmePersistence", info[0].getPersistenceProviderClassName()); assertEquals(0, info[0].getProperties().keySet().size()); assertFalse("Exclude unlisted should default false in 1.0.", info[0].excludeUnlistedClasses()); }
@Test public void testExample4() throws Exception { SimpleNamingContextBuilder builder = SimpleNamingContextBuilder.emptyActivatedContextBuilder(); DataSource ds = new DriverManagerDataSource(); builder.bind("java:comp/env/jdbc/MyDB", ds); PersistenceUnitReader reader = new PersistenceUnitReader( new PathMatchingResourcePatternResolver(), new JndiDataSourceLookup()); String resource = "/org/springframework/orm/jpa/persistence-example4.xml"; PersistenceUnitInfo[] info = reader.readPersistenceUnitInfos(resource); assertNotNull(info); assertEquals(1, info.length); assertEquals("OrderManagement4", info[0].getPersistenceUnitName()); assertEquals(1, info[0].getMappingFileNames().size()); assertEquals("order-mappings.xml", info[0].getMappingFileNames().get(0)); assertEquals(3, info[0].getManagedClassNames().size()); assertEquals("com.acme.Order", info[0].getManagedClassNames().get(0)); assertEquals("com.acme.Customer", info[0].getManagedClassNames().get(1)); assertEquals("com.acme.Item", info[0].getManagedClassNames().get(2)); assertTrue("Exclude unlisted should be true when no value.", info[0].excludeUnlistedClasses()); assertSame(PersistenceUnitTransactionType.RESOURCE_LOCAL, info[0].getTransactionType()); assertEquals(0, info[0].getProperties().keySet().size()); builder.clear(); }
assertEquals(1, pu1.getMappingFileNames().size()); assertEquals("ormap2.xml", pu1.getMappingFileNames().get(0)); assertEquals("com.acme.AcmePersistence", pu2.getPersistenceProviderClassName()); assertEquals(1, pu2.getMappingFileNames().size()); assertEquals("order2.xml", pu2.getMappingFileNames().get(0));
metadata.getPackages().addAll(puInfo.getMappingFileNames());
@Override public List<String> getMappingFileNames() { return delegator.getMappingFileNames(); }
@Override public List<String> getMappingFileNames() { return persistenceUnitInfo.getMappingFileNames(); }
public void setPersistenceEnvironmentInfo(OpenJPAConfiguration conf, PersistenceUnitInfo pui) { // OPENJPA-1460 Fix scope visibility of orm.xml when it is packaged in both ear file and war file if (conf instanceof OpenJPAConfigurationImpl) { Map<String, Object> peMap =((OpenJPAConfigurationImpl)conf).getPersistenceEnvironment(); if (peMap == null) { peMap = new HashMap<String, Object>(); ((OpenJPAConfigurationImpl)conf).setPersistenceEnvironment(peMap); } peMap.put(AbstractCFMetaDataFactory.PERSISTENCE_UNIT_ROOT_URL, pui.getPersistenceUnitRootUrl()); peMap.put(AbstractCFMetaDataFactory.MAPPING_FILE_NAMES, pui.getMappingFileNames()); peMap.put(AbstractCFMetaDataFactory.JAR_FILE_URLS, pui.getJarFileUrls()); } }
public void setPersistenceEnvironmentInfo(OpenJPAConfiguration conf, PersistenceUnitInfo pui) { // OPENJPA-1460 Fix scope visibility of orm.xml when it is packaged in both ear file and war file if (conf instanceof OpenJPAConfigurationImpl) { Map<String, Object> peMap =((OpenJPAConfigurationImpl)conf).getPersistenceEnvironment(); if (peMap == null) { peMap = new HashMap<String, Object>(); ((OpenJPAConfigurationImpl)conf).setPersistenceEnvironment(peMap); } peMap.put(AbstractCFMetaDataFactory.PERSISTENCE_UNIT_ROOT_URL, pui.getPersistenceUnitRootUrl()); peMap.put(AbstractCFMetaDataFactory.MAPPING_FILE_NAMES, pui.getMappingFileNames()); peMap.put(AbstractCFMetaDataFactory.JAR_FILE_URLS, pui.getJarFileUrls()); } }
public void setPersistenceEnvironmentInfo(OpenJPAConfiguration conf, PersistenceUnitInfo pui) { // OPENJPA-1460 Fix scope visibility of orm.xml when it is packaged in both ear file and war file if (conf instanceof OpenJPAConfigurationImpl) { Map<String, Object> peMap =((OpenJPAConfigurationImpl)conf).getPersistenceEnvironment(); if (peMap == null) { peMap = new HashMap<String, Object>(); ((OpenJPAConfigurationImpl)conf).setPersistenceEnvironment(peMap); } peMap.put(AbstractCFMetaDataFactory.PERSISTENCE_UNIT_ROOT_URL, pui.getPersistenceUnitRootUrl()); peMap.put(AbstractCFMetaDataFactory.MAPPING_FILE_NAMES, pui.getMappingFileNames()); peMap.put(AbstractCFMetaDataFactory.JAR_FILE_URLS, pui.getJarFileUrls()); } }
public void setPersistenceEnvironmentInfo(OpenJPAConfiguration conf, PersistenceUnitInfo pui) { // OPENJPA-1460 Fix scope visibility of orm.xml when it is packaged in both ear file and war file if (conf instanceof OpenJPAConfigurationImpl) { Map<String, Object> peMap =((OpenJPAConfigurationImpl)conf).getPersistenceEnvironment(); if (peMap == null) { peMap = new HashMap<String, Object>(); ((OpenJPAConfigurationImpl)conf).setPersistenceEnvironment(peMap); } peMap.put(AbstractCFMetaDataFactory.PERSISTENCE_UNIT_ROOT_URL, pui.getPersistenceUnitRootUrl()); peMap.put(AbstractCFMetaDataFactory.MAPPING_FILE_NAMES, pui.getMappingFileNames()); peMap.put(AbstractCFMetaDataFactory.JAR_FILE_URLS, pui.getJarFileUrls()); } }
public void processResource(final String path, final InputStream is) { if (logger.isDebugEnabled()) { logger.log("DSSR0112", new Object[] { path, unitInfo.getPersistenceUnitName() }); } unitInfo.getMappingFileNames().add(path); }
/** * @param puInfo * the persistence unit info * @param properties * the properties of the persistence unit * * @since 2.0.0 */ public PersistenceParserImpl(PersistenceUnitInfo puInfo, Map<String, Object> properties) { super(); this.puInfo = puInfo; this.provider = puInfo.getPersistenceProviderClassName(); if (puInfo.getProperties() != null) { for (final Entry<Object, Object> entry : puInfo.getProperties().entrySet()) { this.properties.put((String) entry.getKey(), entry.getValue()); } } if (properties != null) { for (final Entry<String, Object> entry : properties.entrySet()) { this.properties.put(entry.getKey(), entry.getValue()); } } this.hasValidators = this.createHasValidators(puInfo); this.metadata = new MetadataImpl(); this.ormMappingFiles = puInfo.getMappingFileNames(); this.parseOrmXmls(); this.metadata.parse(puInfo); }
/** * @param puInfo * the persistence unit info * @param properties * the properties of the persistence unit * * @since 2.0.0 */ public PersistenceParserImpl(PersistenceUnitInfo puInfo, Map<String, Object> properties) { super(); this.puInfo = puInfo; this.provider = puInfo.getPersistenceProviderClassName(); if (puInfo.getProperties() != null) { for (final Entry<Object, Object> entry : puInfo.getProperties().entrySet()) { this.properties.put((String) entry.getKey(), entry.getValue()); } } if (properties != null) { for (final Entry<String, Object> entry : properties.entrySet()) { this.properties.put(entry.getKey(), entry.getValue()); } } this.hasValidators = this.createHasValidators(puInfo); this.metadata = new MetadataImpl(); this.ormMappingFiles = puInfo.getMappingFileNames(); this.parseOrmXmls(); this.metadata.parse(puInfo); }
/** * @param puInfo * the persistence unit info * @param properties * the properties of the persistence unit * * @since 2.0.0 */ public PersistenceParserImpl(PersistenceUnitInfo puInfo, Map<String, Object> properties) { super(); this.puInfo = puInfo; this.provider = puInfo.getPersistenceProviderClassName(); if (puInfo.getProperties() != null) { for (final Entry<Object, Object> entry : puInfo.getProperties().entrySet()) { this.properties.put((String) entry.getKey(), entry.getValue()); } } if (properties != null) { for (final Entry<String, Object> entry : properties.entrySet()) { this.properties.put(entry.getKey(), entry.getValue()); } } this.hasValidators = this.createHasValidators(puInfo); this.metadata = new MetadataImpl(); this.ormMappingFiles = puInfo.getMappingFileNames(); this.parseOrmXmls(); this.metadata.parse(puInfo); }
private Map<URL, Document> readExplicitlySpecifiedMappingFiles(boolean throwExceptionOnFail) { Map<URL, Document> list = new HashMap<URL, Document>(); final PersistenceUnitInfo puInfo = m_project.getPUInfo(); for (String mf : puInfo.getMappingFileNames()) { try { Enumeration<URL> mfURLs = m_loader.getResources(mf); if (mfURLs.hasMoreElements()) { URL nextURL = mfURLs.nextElement(); if (mfURLs.hasMoreElements()) { handleORMException(ValidationException.nonUniqueMappingFileName(puInfo.getPersistenceUnitName(), mf), mf, throwExceptionOnFail); } InputStream stream = null; stream = nextURL.openStream(); Document document = XMLHelper.parseDocument(stream, nextURL.getFile(), m_loader); list.put(nextURL, document); try { stream.close(); } catch (IOException e) {} } else { handleORMException(ValidationException.mappingFileNotFound(puInfo.getPersistenceUnitName(), mf), mf, throwExceptionOnFail); } } catch (IOException e) { handleORMException(PersistenceUnitLoadingException.exceptionLoadingORMXML(mf, e), mf, throwExceptionOnFail); } } return list; }
public Ejb3Configuration configure(String resource) throws HibernateException { Thread thread = null; ClassLoader contextClassLoader = null; if (overridenClassLoader != null) { thread = Thread.currentThread(); contextClassLoader = thread.getContextClassLoader(); thread.setContextClassLoader( overridenClassLoader ); } try { Properties properties = new Properties(); properties.setProperty( HibernatePersistence.CFG_FILE, resource); configure( properties, new HashMap() ); return this; } finally { if (thread != null) thread.setContextClassLoader( contextClassLoader ); } }
for (String mappingFileName : oldPui.getMappingFileNames()) { if (!pui.getMappingFileNames().contains(mappingFileName)) { LOG.debug("Adding mapping file to persistence unit {}.", mappingFileName, persistenceUnitName);