use of org.eclipse.persistence.internal.jpa.metadata.xml.XMLEntityMappings in project eclipselink by eclipse-ee4j.
the class MetadataProcessor method setClassLoader.
/**
* INTERNAL:
* Use this method to set the correct class loader that should be used
* during processing. Currently, the class loader should only change
* once, from preDeploy to deploy.
*/
public void setClassLoader(ClassLoader loader) {
m_loader = loader;
m_factory.setLoader(loader);
// Update the loader on all the entity mappings for this project.
for (XMLEntityMappings entityMappings : m_project.getEntityMappings()) {
entityMappings.setLoader(m_loader);
}
}
use of org.eclipse.persistence.internal.jpa.metadata.xml.XMLEntityMappings in project eclipselink by eclipse-ee4j.
the class MetadataProcessor method loadMappingFiles.
/**
* INTERNAL:
* This method is responsible for figuring out list of mapping files to
* read into XMLEntityMappings objects and store on the project. Note,
* the order the files are discovered and read is very important so do
* not change the order of invocation.
*/
public void loadMappingFiles(boolean throwExceptionOnFail) {
// Read all the standard XML mapping files first.
loadStandardMappingFiles(MetadataHelper.JPA_ORM_FILE);
// Read all the explicitly specified mapping files second.
loadSpecifiedMappingFiles(throwExceptionOnFail);
// Read all the standard eclipselink files last (if the user hasn't
// explicitly excluded them). The eclipselink orm files will be
// processed last therefore allowing them to override and merge
// metadata where necessary. Note: we want the eclipselink orm
// metadata to merge into standard jpa files and not vice versa.
// Loading them last will ensure this happens.
Boolean excludeEclipseLinkORM = Boolean.valueOf((String) m_project.getPersistenceUnitInfo().getProperties().get(PersistenceUnitProperties.EXCLUDE_ECLIPSELINK_ORM_FILE));
if (!excludeEclipseLinkORM) {
loadStandardMappingFiles(MetadataHelper.ECLIPSELINK_ORM_FILE);
}
if (m_metadataSource != null) {
XMLEntityMappings entityMappings = m_metadataSource.getEntityMappings(this.m_predeployProperties, m_loader, m_session.getSessionLog());
if (entityMappings != null) {
m_project.addEntityMappings(entityMappings);
}
}
}
use of org.eclipse.persistence.internal.jpa.metadata.xml.XMLEntityMappings in project eclipselink by eclipse-ee4j.
the class PLSQLRecordTypeTestSuite method testJPAPLSQLRecordMetadata.
@Test
@SuppressWarnings({ "unchecked" })
public void testJPAPLSQLRecordMetadata() {
if (dbProcedures == null || dbProcedures.isEmpty()) {
fail("No types were generated.");
}
XMLEntityMappings mappings = null;
try {
JPAMetadataGenerator gen = new JPAMetadataGenerator(DEFAULT_PACKAGE_NAME, databasePlatform);
mappings = gen.generateXmlEntityMappings(dbProcedures);
} catch (Exception x) {
x.printStackTrace();
fail("An unexpected exception occurred: " + x.getMessage());
}
if (mappings == null) {
fail("No JPA metadata was generated");
}
ByteArrayOutputStream metadata = new ByteArrayOutputStream();
XMLEntityMappingsWriter.write(mappings, metadata);
Document testDoc = xmlParser.parse(new StringReader(metadata.toString()));
removeEmptyTextNodes(testDoc);
Document controlDoc = xmlParser.parse(new StringReader(typemetadata));
removeEmptyTextNodes(controlDoc);
assertTrue("Metadata comparison failed. Expected:\n" + documentToString(controlDoc) + "\nActual\n" + documentToString(testDoc), comparer.isNodeEqual(controlDoc, testDoc));
}
use of org.eclipse.persistence.internal.jpa.metadata.xml.XMLEntityMappings in project eclipselink by eclipse-ee4j.
the class ProcedureOverloadTestSuite method testProcedureOverload.
@Test
@SuppressWarnings({ "unchecked" })
public void testProcedureOverload() {
if (dbProcedures == null || dbProcedures.isEmpty()) {
fail("No types were generated.");
}
XMLEntityMappings mappings = null;
try {
JPAMetadataGenerator gen = new JPAMetadataGenerator(DEFAULT_PACKAGE_NAME, databasePlatform);
mappings = gen.generateXmlEntityMappings(dbProcedures);
} catch (Exception x) {
fail("An unexpected exception occurred: " + x.getMessage());
}
if (mappings == null) {
fail("No JPA metadata was generated");
}
ByteArrayOutputStream metadata = new ByteArrayOutputStream();
XMLEntityMappingsWriter.write(mappings, metadata);
Document testDoc = xmlParser.parse(new StringReader(metadata.toString()));
removeEmptyTextNodes(testDoc);
Document controlDoc = xmlParser.parse(new StringReader(procedureMetadata));
removeEmptyTextNodes(controlDoc);
assertTrue("Metadata comparison failed. Expected:\n" + documentToString(controlDoc) + "\nActual\n" + documentToString(testDoc), comparer.isNodeEqual(controlDoc, testDoc));
}
use of org.eclipse.persistence.internal.jpa.metadata.xml.XMLEntityMappings in project eclipselink by eclipse-ee4j.
the class ProcedureTypeTestSuite method testJPAProcedureMetadata.
@Test
@SuppressWarnings({ "unchecked" })
public void testJPAProcedureMetadata() {
if (dbProcedures == null || dbProcedures.isEmpty()) {
fail("No types were generated.");
}
XMLEntityMappings mappings = null;
try {
JPAMetadataGenerator gen = new JPAMetadataGenerator(DEFAULT_PACKAGE_NAME, databasePlatform);
mappings = gen.generateXmlEntityMappings(dbProcedures);
} catch (Exception x) {
fail("An unexpected exception occurred: " + x.getMessage());
}
if (mappings == null) {
fail("No JPA metadata was generated");
}
ByteArrayOutputStream metadata = new ByteArrayOutputStream();
XMLEntityMappingsWriter.write(mappings, metadata);
Document testDoc = xmlParser.parse(new StringReader(metadata.toString()));
removeEmptyTextNodes(testDoc);
Document controlDoc = xmlParser.parse(new StringReader(procedureMetadata));
removeEmptyTextNodes(controlDoc);
assertTrue("Metadata comparison failed. Expected:\n" + documentToString(controlDoc) + "\nActual\n" + documentToString(testDoc), comparer.isNodeEqual(controlDoc, testDoc));
}
Aggregations