use of org.hibernate.jpamodelgen.xml.jaxb.Persistence in project hibernate-orm by hibernate.
the class JpaDescriptorParser method getPersistence.
private Persistence getPersistence() {
Persistence persistence = null;
String persistenceXmlLocation = context.getPersistenceXmlLocation();
InputStream stream = xmlParserHelper.getInputStreamForResource(persistenceXmlLocation);
if (stream == null) {
return null;
}
try {
Schema schema = xmlParserHelper.getSchema(PERSISTENCE_SCHEMA);
persistence = xmlParserHelper.getJaxbRoot(stream, Persistence.class, schema);
} catch (XmlParsingException e) {
context.logMessage(Diagnostic.Kind.WARNING, "Unable to parse persistence.xml: " + e.getMessage());
}
try {
stream.close();
} catch (IOException e) {
// eat it
}
return persistence;
}
use of org.hibernate.jpamodelgen.xml.jaxb.Persistence in project hibernate-orm by hibernate.
the class JpaDescriptorParser method determineMappingFileNames.
private Collection<String> determineMappingFileNames() {
Collection<String> mappingFileNames = new ArrayList<String>();
Persistence persistence = getPersistence();
if (persistence != null) {
// get mapping file names from persistence.xml
List<Persistence.PersistenceUnit> persistenceUnits = persistence.getPersistenceUnit();
for (Persistence.PersistenceUnit unit : persistenceUnits) {
mappingFileNames.addAll(unit.getMappingFile());
}
}
// /META-INF/orm.xml is implicit
mappingFileNames.add(DEFAULT_ORM_XML_LOCATION);
// not really part of the official spec, but the processor allows to specify mapping files directly as
// command line options
mappingFileNames.addAll(context.getOrmXmlFiles());
return mappingFileNames;
}
Aggregations